How to use within method of Capybara Package

Best Capybara code snippet using Capybara.within

session.rb

Source:session.rb Github

copy

Full Screen

...55 ].freeze56 SESSION_METHODS = %i[57 body html source current_url current_host current_path58 execute_script evaluate_script visit refresh go_back go_forward59 within within_element within_fieldset within_table within_frame switch_to_frame60 current_window windows open_new_window switch_to_window within_window window_opened_by61 save_page save_and_open_page save_screenshot62 save_and_open_screenshot reset_session! response_headers63 status_code current_scope64 assert_current_path assert_no_current_path has_current_path? has_no_current_path?65 ].freeze + DOCUMENT_METHODS66 MODAL_METHODS = %i[67 accept_alert accept_confirm dismiss_confirm accept_prompt dismiss_prompt68 ].freeze69 DSL_METHODS = NODE_METHODS + SESSION_METHODS + MODAL_METHODS70 attr_reader :mode, :app, :server71 attr_accessor :synchronized72 def initialize(mode, app = nil)73 raise TypeError, 'The second parameter to Session::new should be a rack app if passed.' if app && !app.respond_to?(:call)74 @@instance_created = true75 @mode = mode76 @app = app77 if block_given?78 raise 'A configuration block is only accepted when Capybara.threadsafe == true' unless Capybara.threadsafe79 yield config80 end81 @server = if config.run_server && @app && driver.needs_server?82 server_options = { port: config.server_port, host: config.server_host, reportable_errors: config.server_errors }83 server_options[:extra_middleware] = [Capybara::Server::AnimationDisabler] if config.disable_animation84 Capybara::Server.new(@app, server_options).boot85 end86 @touched = false87 end88 def driver89 @driver ||= begin90 unless Capybara.drivers.key?(mode)91 other_drivers = Capybara.drivers.keys.map(&:inspect)92 raise Capybara::DriverNotFoundError, "no driver called #{mode.inspect} was found, available drivers: #{other_drivers.join(', ')}"93 end94 driver = Capybara.drivers[mode].call(app)95 driver.session = self if driver.respond_to?(:session=)96 driver97 end98 end99 ##100 #101 # Reset the session (i.e. remove cookies and navigate to blank page)102 #103 # This method does not:104 #105 # * accept modal dialogs if they are present (Selenium driver now does, others may not)106 # * clear browser cache/HTML 5 local storage/IndexedDB/Web SQL database/etc.107 # * modify state of the driver/underlying browser in any other way108 #109 # as doing so will result in performance downsides and it's not needed to do everything from the list above for most apps.110 #111 # If you want to do anything from the list above on a general basis you can:112 #113 # * write RSpec/Cucumber/etc. after hook114 # * monkeypatch this method115 # * use Ruby's `prepend` method116 #117 def reset!118 if @touched119 driver.reset!120 @touched = false121 end122 @server&.wait_for_pending_requests123 raise_server_error!124 end125 alias_method :cleanup!, :reset!126 alias_method :reset_session!, :reset!127 ##128 #129 # Raise errors encountered in the server130 #131 def raise_server_error!132 return if @server.nil? || !@server.error133 # Force an explanation for the error being raised as the exception cause134 begin135 if config.raise_server_errors136 raise CapybaraError, 'Your application server raised an error - It has been raised in your test code because Capybara.raise_server_errors == true'137 end138 rescue CapybaraError139 # needed to get the cause set correctly in JRuby -- otherwise we could just do raise @server.error140 raise @server.error, @server.error.message, @server.error.backtrace141 ensure142 @server.reset_error!143 end144 end145 ##146 #147 # Returns a hash of response headers. Not supported by all drivers (e.g. Selenium)148 #149 # @return [Hash{String => String}] A hash of response headers.150 #151 def response_headers152 driver.response_headers153 end154 ##155 #156 # Returns the current HTTP status code as an Integer. Not supported by all drivers (e.g. Selenium)157 #158 # @return [Integer] Current HTTP status code159 #160 def status_code161 driver.status_code162 end163 ##164 #165 # @return [String] A snapshot of the DOM of the current document, as it looks right now (potentially modified by JavaScript).166 #167 def html168 driver.html169 end170 alias_method :body, :html171 alias_method :source, :html172 ##173 #174 # @return [String] Path of the current page, without any domain information175 #176 def current_path177 # Addressable parsing is more lenient than URI178 uri = ::Addressable::URI.parse(current_url)179 # Addressable doesn't support opaque URIs - we want nil here180 return nil if uri&.scheme == 'about'181 path = uri&.path182 path unless path&.empty?183 end184 ##185 #186 # @return [String] Host of the current page187 #188 def current_host189 uri = URI.parse(current_url)190 "#{uri.scheme}://#{uri.host}" if uri.host191 end192 ##193 #194 # @return [String] Fully qualified URL of the current page195 #196 def current_url197 driver.current_url198 end199 ##200 #201 # Navigate to the given URL. The URL can either be a relative URL or an absolute URL202 # The behaviour of either depends on the driver.203 #204 # session.visit('/foo')205 # session.visit('http://google.com')206 #207 # For drivers which can run against an external application, such as the selenium driver208 # giving an absolute URL will navigate to that page. This allows testing applications209 # running on remote servers. For these drivers, setting {Capybara.app_host} will make the210 # remote server the default. For example:211 #212 # Capybara.app_host = 'http://google.com'213 # session.visit('/') # visits the google homepage214 #215 # If {Capybara.always_include_port} is set to true and this session is running against216 # a rack application, then the port that the rack application is running on will automatically217 # be inserted into the URL. Supposing the app is running on port `4567`, doing something like:218 #219 # visit("http://google.com/test")220 #221 # Will actually navigate to `http://google.com:4567/test`.222 #223 # @param [#to_s] visit_uri The URL to navigate to. The parameter will be cast to a String.224 #225 def visit(visit_uri)226 raise_server_error!227 @touched = true228 visit_uri = ::Addressable::URI.parse(visit_uri.to_s)229 base = config.app_host230 base ||= "http#{'s' if @server.using_ssl?}://#{@server.host}:#{@server.port}" if @server231 uri_base = ::Addressable::URI.parse(base)232 if uri_base && [nil, 'http', 'https'].include?(visit_uri.scheme)233 if visit_uri.relative?234 uri_base.port ||= @server.port if @server && config.always_include_port235 visit_uri_parts = visit_uri.to_hash.delete_if { |_k, v| v.nil? }236 # Useful to people deploying to a subdirectory237 # and/or single page apps where only the url fragment changes238 visit_uri_parts[:path] = uri_base.path + visit_uri.path239 visit_uri = uri_base.merge(visit_uri_parts)240 elsif @server && config.always_include_port241 visit_uri.port ||= @server.port242 end243 end244 driver.visit(visit_uri.to_s)245 end246 ##247 #248 # Refresh the page249 #250 def refresh251 raise_server_error!252 driver.refresh253 end254 ##255 #256 # Move back a single entry in the browser's history.257 #258 def go_back259 driver.go_back260 end261 ##262 #263 # Move forward a single entry in the browser's history.264 #265 def go_forward266 driver.go_forward267 end268 ##269 #270 # Executes the given block within the context of a node. `within` takes the271 # same options as `find`, as well as a block. For the duration of the272 # block, any command to Capybara will be handled as though it were scoped273 # to the given element.274 #275 # within(:xpath, './/div[@id="delivery-address"]') do276 # fill_in('Street', with: '12 Main Street')277 # end278 #279 # Just as with `find`, if multiple elements match the selector given to280 # `within`, an error will be raised, and just as with `find`, this281 # behaviour can be controlled through the `:match` and `:exact` options.282 #283 # It is possible to omit the first parameter, in that case, the selector is284 # assumed to be of the type set in Capybara.default_selector.285 #286 # within('div#delivery-address') do287 # fill_in('Street', with: '12 Main Street')288 # end289 #290 # Note that a lot of uses of `within` can be replaced more succinctly with291 # chaining:292 #293 # find('div#delivery-address').fill_in('Street', with: '12 Main Street')294 #295 # @overload within(*find_args)296 # @param (see Capybara::Node::Finders#all)297 #298 # @overload within(a_node)299 # @param [Capybara::Node::Base] a_node The node in whose scope the block should be evaluated300 #301 # @raise [Capybara::ElementNotFound] If the scope can't be found before time expires302 #303 def within(*args)304 new_scope = args.first.respond_to?(:to_capybara_node) ? args.first.to_capybara_node : find(*args)305 begin306 scopes.push(new_scope)307 yield if block_given?308 ensure309 scopes.pop310 end311 end312 alias_method :within_element, :within313 ##314 #315 # Execute the given block within the a specific fieldset given the id or legend of that fieldset.316 #317 # @param [String] locator Id or legend of the fieldset318 #319 def within_fieldset(locator)320 within(:fieldset, locator) { yield }321 end322 ##323 #324 # Execute the given block within the a specific table given the id or caption of that table.325 #326 # @param [String] locator Id or caption of the table327 #328 def within_table(locator)329 within(:table, locator) { yield }330 end331 ##332 #333 # Switch to the given frame334 #335 # If you use this method you are responsible for making sure you switch back to the parent frame when done in the frame changed to.336 # Capybara::Session#within_frame is preferred over this method and should be used when possible.337 # May not be supported by all drivers.338 #339 # @overload switch_to_frame(element)340 # @param [Capybara::Node::Element] iframe/frame element to switch to341 # @overload switch_to_frame(:parent)342 # Switch to the parent element343 # @overload switch_to_frame(:top)344 # Switch to the top level document345 #346 def switch_to_frame(frame)347 case frame348 when Capybara::Node::Element349 driver.switch_to_frame(frame)350 scopes.push(:frame)351 when :parent352 if scopes.last != :frame353 raise Capybara::ScopeError, "`switch_to_frame(:parent)` cannot be called from inside a descendant frame's "\354 '`within` block.'355 end356 scopes.pop357 driver.switch_to_frame(:parent)358 when :top359 idx = scopes.index(:frame)360 if idx361 if scopes.slice(idx..-1).any? { |scope| ![:frame, nil].include?(scope) }362 raise Capybara::ScopeError, "`switch_to_frame(:top)` cannot be called from inside a descendant frame's "\363 '`within` block.'364 end365 scopes.slice!(idx..-1)366 driver.switch_to_frame(:top)367 end368 else369 raise ArgumentError, 'You must provide a frame element, :parent, or :top when calling switch_to_frame'370 end371 end372 ##373 #374 # Execute the given block within the given iframe using given frame, frame name/id or index.375 # May not be supported by all drivers.376 #377 # @overload within_frame(element)378 # @param [Capybara::Node::Element] frame element379 # @overload within_frame([kind = :frame], locator, **options)380 # @param [Symbol] kind Optional selector type (:frame, :css, :xpath, etc.) - Defaults to :frame381 # @param [String] locator The locator for the given selector kind. For :frame this is the name/id of a frame/iframe element382 # @overload within_frame(index)383 # @param [Integer] index index of a frame (0 based)384 def within_frame(*args)385 switch_to_frame(_find_frame(*args))386 begin387 yield if block_given?388 ensure389 switch_to_frame(:parent)390 end391 end392 ##393 # @return [Capybara::Window] current window394 #395 def current_window396 Window.new(self, driver.current_window_handle)397 end398 ##399 # Get all opened windows.400 # The order of windows in returned array is not defined.401 # The driver may sort windows by their creation time but it's not required.402 #403 # @return [Array<Capybara::Window>] an array of all windows404 #405 def windows406 driver.window_handles.map do |handle|407 Window.new(self, handle)408 end409 end410 ##411 # Open new window.412 # Current window doesn't change as the result of this call.413 # It should be switched to explicitly.414 #415 # @return [Capybara::Window] window that has been opened416 #417 def open_new_window418 window_opened_by do419 driver.open_new_window420 end421 end422 ##423 # @overload switch_to_window(&block)424 # Switches to the first window for which given block returns a value other than false or nil.425 # If window that matches block can't be found, the window will be switched back and `WindowError` will be raised.426 # @example427 # window = switch_to_window { title == 'Page title' }428 # @raise [Capybara::WindowError] if no window matches given block429 # @overload switch_to_window(window)430 # @param window [Capybara::Window] window that should be switched to431 # @raise [Capybara::Driver::Base#no_such_window_error] if nonexistent (e.g. closed) window was passed432 #433 # @return [Capybara::Window] window that has been switched to434 # @raise [Capybara::ScopeError] if this method is invoked inside `within` or435 # `within_frame` methods436 # @raise [ArgumentError] if both or neither arguments were provided437 #438 def switch_to_window(window = nil, **options, &window_locator)439 raise ArgumentError, '`switch_to_window` can take either a block or a window, not both' if window && block_given?440 raise ArgumentError, '`switch_to_window`: either window or block should be provided' if !window && !block_given?441 unless scopes.last.nil?442 raise Capybara::ScopeError, '`switch_to_window` is not supposed to be invoked from '\443 '`within` or `within_frame` blocks.'444 end445 _switch_to_window(window, options, &window_locator)446 end447 ##448 # This method does the following:449 #450 # 1. Switches to the given window (it can be located by window instance/lambda/string).451 # 2. Executes the given block (within window located at previous step).452 # 3. Switches back (this step will be invoked even if exception will happen at second step)453 #454 # @overload within_window(window) { do_something }455 # @param window [Capybara::Window] instance of `Capybara::Window` class456 # that will be switched to457 # @raise [driver#no_such_window_error] if nonexistent (e.g. closed) window was passed458 # @overload within_window(proc_or_lambda) { do_something }459 # @param lambda [Proc] lambda. First window for which lambda460 # returns a value other than false or nil will be switched to.461 # @example462 # within_window(->{ page.title == 'Page title' }) { click_button 'Submit' }463 # @raise [Capybara::WindowError] if no window matching lambda was found464 #465 # @raise [Capybara::ScopeError] if this method is invoked inside `within_frame` method466 # @return value returned by the block467 #468 def within_window(window_or_proc)469 original = current_window470 scopes << nil471 begin472 case window_or_proc473 when Capybara::Window474 _switch_to_window(window_or_proc) unless original == window_or_proc475 when Proc476 _switch_to_window { window_or_proc.call }477 else478 raise ArgumentError('`#within_window` requires a `Capybara::Window` instance or a lambda')479 end480 begin481 yield if block_given?482 ensure483 _switch_to_window(original) unless original == window_or_proc484 end485 ensure486 scopes.pop487 end488 end489 ##490 # Get the window that has been opened by the passed block.491 # It will wait for it to be opened (in the same way as other Capybara methods wait).492 # It's better to use this method than `windows.last`493 # {https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html#h_note_10 as order of windows isn't defined in some drivers}494 #495 # @overload window_opened_by(**options, &block)496 # @param options [Hash]497 # @option options [Numeric] :wait (Capybara.default_max_wait_time) maximum wait time498 # @return [Capybara::Window] the window that has been opened within a block499 # @raise [Capybara::WindowError] if block passed to window hasn't opened window500 # or opened more than one window501 #502 def window_opened_by(**options)503 old_handles = driver.window_handles504 yield505 wait_time = Capybara::Queries::BaseQuery.wait(options, config.default_max_wait_time)506 document.synchronize(wait_time, errors: [Capybara::WindowError]) do507 opened_handles = (driver.window_handles - old_handles)508 if opened_handles.size != 1509 raise Capybara::WindowError, 'block passed to #window_opened_by '\510 "opened #{opened_handles.size} windows instead of 1"511 end512 Window.new(self, opened_handles.first)513 end514 end515 ##516 #517 # Execute the given script, not returning a result. This is useful for scripts that return518 # complex objects, such as jQuery statements. +execute_script+ should be used over519 # +evaluate_script+ whenever possible.520 #521 # @param [String] script A string of JavaScript to execute522 # @param args Optional arguments that will be passed to the script. Driver support for this is optional and types of objects supported may differ between drivers523 #524 def execute_script(script, *args)525 @touched = true526 driver.execute_script(script, *driver_args(args))527 end528 ##529 #530 # Evaluate the given JavaScript and return the result. Be careful when using this with531 # scripts that return complex objects, such as jQuery statements. +execute_script+ might532 # be a better alternative.533 #534 # @param [String] script A string of JavaScript to evaluate535 # @return [Object] The result of the evaluated JavaScript (may be driver specific)536 #537 def evaluate_script(script, *args)538 @touched = true539 result = driver.evaluate_script(script.strip, *driver_args(args))540 element_script_result(result)541 end542 ##543 #544 # Evaluate the given JavaScript and obtain the result from a callback function which will be passed as the last argument to the script.545 #546 # @param [String] script A string of JavaScript to evaluate547 # @return [Object] The result of the evaluated JavaScript (may be driver specific)548 #549 def evaluate_async_script(script, *args)550 @touched = true551 result = driver.evaluate_async_script(script, *driver_args(args))552 element_script_result(result)553 end554 ##555 #556 # Execute the block, accepting a alert.557 #558 # @!macro modal_params559 # Expects a block whose actions will trigger the display modal to appear560 # @example561 # $0 do562 # click_link('link that triggers appearance of system modal')563 # end564 # @overload $0(text, **options, &blk)565 # @param text [String, Regexp] Text or regex to match against the text in the modal. If not provided any modal is matched566 # @option options [Numeric] :wait (Capybara.default_max_wait_time) Maximum time to wait for the modal to appear after executing the block.567 # @yield Block whose actions will trigger the system modal568 # @overload $0(**options, &blk)569 # @option options [Numeric] :wait (Capybara.default_max_wait_time) Maximum time to wait for the modal to appear after executing the block.570 # @yield Block whose actions will trigger the system modal571 # @return [String] the message shown in the modal572 # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found573 #574 def accept_alert(text = nil, **options, &blk)575 accept_modal(:alert, text, options, &blk)576 end577 ##578 #579 # Execute the block, accepting a confirm.580 #581 # @macro modal_params582 #583 def accept_confirm(text = nil, **options, &blk)584 accept_modal(:confirm, text, options, &blk)585 end586 ##587 #588 # Execute the block, dismissing a confirm.589 #590 # @macro modal_params591 #592 def dismiss_confirm(text = nil, **options, &blk)593 dismiss_modal(:confirm, text, options, &blk)594 end595 ##596 #597 # Execute the block, accepting a prompt, optionally responding to the prompt.598 #599 # @macro modal_params600 # @option options [String] :with Response to provide to the prompt601 #602 def accept_prompt(text = nil, **options, &blk)603 accept_modal(:prompt, text, options, &blk)604 end605 ##606 #607 # Execute the block, dismissing a prompt.608 #609 # @macro modal_params610 #611 def dismiss_prompt(text = nil, **options, &blk)612 dismiss_modal(:prompt, text, options, &blk)613 end614 ##615 #616 # Save a snapshot of the page. If `Capybara.asset_host` is set it will inject `base` tag617 # pointing to `asset_host`.618 #619 # If invoked without arguments it will save file to `Capybara.save_path`620 # and file will be given randomly generated filename. If invoked with a relative path621 # the path will be relative to `Capybara.save_path`622 #623 # @param [String] path the path to where it should be saved624 # @return [String] the path to which the file was saved625 #626 def save_page(path = nil)627 prepare_path(path, 'html').tap do |p|628 File.write(p, Capybara::Helpers.inject_asset_host(body, host: config.asset_host), mode: 'wb')629 end630 end631 ##632 #633 # Save a snapshot of the page and open it in a browser for inspection.634 #635 # If invoked without arguments it will save file to `Capybara.save_path`636 # and file will be given randomly generated filename. If invoked with a relative path637 # the path will be relative to `Capybara.save_path`638 #639 # @param [String] path the path to where it should be saved640 #641 def save_and_open_page(path = nil)642 save_page(path).tap { |p| open_file(p) }643 end644 ##645 #646 # Save a screenshot of page.647 #648 # If invoked without arguments it will save file to `Capybara.save_path`649 # and file will be given randomly generated filename. If invoked with a relative path650 # the path will be relative to `Capybara.save_path`651 #652 # @param [String] path the path to where it should be saved653 # @param [Hash] options a customizable set of options654 # @return [String] the path to which the file was saved655 def save_screenshot(path = nil, **options)656 prepare_path(path, 'png').tap { |p| driver.save_screenshot(p, options) }657 end658 ##659 #660 # Save a screenshot of the page and open it for inspection.661 #662 # If invoked without arguments it will save file to `Capybara.save_path`663 # and file will be given randomly generated filename. If invoked with a relative path664 # the path will be relative to `Capybara.save_path`665 #666 # @param [String] path the path to where it should be saved667 # @param [Hash] options a customizable set of options668 #669 def save_and_open_screenshot(path = nil, **options)670 # rubocop:disable Lint/Debugger671 save_screenshot(path, options).tap { |p| open_file(p) }672 # rubocop:enable Lint/Debugger673 end674 def document675 @document ||= Capybara::Node::Document.new(self, driver)676 end677 NODE_METHODS.each do |method|678 define_method method do |*args, &block|679 @touched = true680 current_scope.send(method, *args, &block)681 end682 end683 DOCUMENT_METHODS.each do |method|684 define_method method do |*args, &block|685 document.send(method, *args, &block)686 end687 end688 def inspect689 %(#<Capybara::Session>)690 end691 def current_scope692 scope = scopes.last693 [nil, :frame].include?(scope) ? document : scope694 end695 ##696 #697 # Yield a block using a specific wait time698 #699 def using_wait_time(seconds)700 if Capybara.threadsafe701 begin702 previous_wait_time = config.default_max_wait_time703 config.default_max_wait_time = seconds704 yield705 ensure706 config.default_max_wait_time = previous_wait_time707 end708 else709 Capybara.using_wait_time(seconds) { yield }710 end711 end712 ##713 #714 # Accepts a block to set the configuration options if Capybara.threadsafe == true. Note that some options only have an effect715 # if set at initialization time, so look at the configuration block that can be passed to the initializer too716 #717 def configure718 raise 'Session configuration is only supported when Capybara.threadsafe == true' unless Capybara.threadsafe719 yield config720 end721 def self.instance_created?722 @@instance_created723 end724 def config725 @config ||= if Capybara.threadsafe726 Capybara.session_options.dup727 else728 Capybara::ReadOnlySessionConfig.new(Capybara.session_options)729 end730 end731 private732 @@instance_created = false733 def driver_args(args)734 args.map { |arg| arg.is_a?(Capybara::Node::Element) ? arg.base : arg }735 end736 def accept_modal(type, text_or_options, options, &blk)737 driver.accept_modal(type, modal_options(text_or_options, options), &blk)738 end739 def dismiss_modal(type, text_or_options, options, &blk)740 driver.dismiss_modal(type, modal_options(text_or_options, options), &blk)741 end742 def modal_options(text = nil, **options)743 options[:text] ||= text unless text.nil?744 options[:wait] ||= config.default_max_wait_time745 options746 end747 def open_file(path)748 require 'launchy'749 Launchy.open(path)750 rescue LoadError751 warn "File saved to #{path}.\nPlease install the launchy gem to open the file automatically."752 end753 def prepare_path(path, extension)754 File.expand_path(path || default_fn(extension), config.save_path).tap { |p| FileUtils.mkdir_p(File.dirname(p)) }755 end756 def default_fn(extension)757 timestamp = Time.new.strftime('%Y%m%d%H%M%S')758 "capybara-#{timestamp}#{rand(10**10)}.#{extension}"759 end760 def scopes761 @scopes ||= [nil]762 end763 def element_script_result(arg)764 case arg765 when Array766 arg.map { |e| element_script_result(e) }767 when Hash768 arg.each { |k, v| arg[k] = element_script_result(v) }769 when Capybara::Driver::Node770 Capybara::Node::Element.new(self, arg, nil, nil)771 else772 arg773 end774 end775 def _find_frame(*args)776 return find(:frame) if args.length.zero?777 case args[0]778 when Capybara::Node::Element779 args[0]780 when String, Hash781 find(:frame, *args)782 when Symbol783 find(*args)784 when Integer785 idx = args[0]786 all(:frame, minimum: idx + 1)[idx]787 else788 raise TypeError789 end790 end791 def _switch_to_window(window = nil, **options)792 raise Capybara::ScopeError, 'Window cannot be switched inside a `within_frame` block' if scopes.include?(:frame)793 raise Capybara::ScopeError, 'Window cannot be switch inside a `within` block' unless scopes.last.nil?794 if window795 driver.switch_to_window(window.handle)796 window797 else798 wait_time = Capybara::Queries::BaseQuery.wait(options, config.default_max_wait_time)799 document.synchronize(wait_time, errors: [Capybara::WindowError]) do800 original_window_handle = driver.current_window_handle801 begin802 driver.window_handles.each do |handle|803 driver.switch_to_window handle804 return Window.new(self, handle) if yield805 end806 rescue StandardError => e807 driver.switch_to_window(original_window_handle)...

Full Screen

Full Screen

within

Using AI Code Generation

copy

Full Screen

1 page.driver.browser.manage.window.resize_to(1440, 900)2 page.driver.browser.manage.window.resize_to(1024, 768)3 page.driver.browser.manage.window.resize_to(720, 1280)4 page.driver.browser.manage.window.resize_to(480, 800)5 page.driver.browser.manage.window.resize_to(320, 568)6 page.driver.browser.manage.window.resize_to(320, 480)7 page.driver.browser.manage.window.resize_to(375, 667)8 page.driver.browser.manage.window.resize_to(414, 736)9 page.driver.browser.manage.window.resize_to(768, 1024)10 page.driver.browser.manage.window.resize_to(800, 1280)11 page.driver.browser.manage.window.resize_to(900, 1440)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Capybara automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful