How to use pause method of Selenium.WebDriver Package

Best Selenium code snippet using Selenium.WebDriver.pause

web_driver_base.rb

Source:web_driver_base.rb Github

copy

Full Screen

...14end15class KaikiFS::WebDriver::Base16 include Log4r17 attr_reader :driver, :env, :username, :screenshot_dir, :log18 attr_accessor :headless, :is_headless, :pause_time, :record19 # The basename of the json file that contains all environment information20 ENVS_FILE = "envs.json"21 # The default timeout for Waits22 DEFAULT_TIMEOUT = 823 # The default dimensions for the headless display24 DEFAULT_DIMENSIONS = "1024x768x24"25 # The pair of selectors that will identify the Main Menu link to `find_element`26 MAIN_MENU_LINK = [:link_text, 'Main Menu']27 # I think just a more attractive form of this constant?28 def main_menu_link; MAIN_MENU_LINK; end29 extend Forwardable30 def_delegators :@driver, :close, :current_url, :execute_script, :page_source, :quit, :switch_to,31 :window_handle, :window_handles32 def initialize(username, password, options={})33 @username = username34 @password = password35 @standard_envs = JSON.parse(IO.readlines(ENVS_FILE).map{ |l| l.gsub(/[\r\n]/, '') }.join(""))36 @envs = options[:envs] ?37 @standard_envs.select { |k,v| options[:envs].include? k } :38 @standard_envs39 if @envs.empty?40 @envs = {41 options[:envs].first => { "code" => options[:envs].first, "url" => options[:envs].first }42 }43 end44 if @envs.keys.size == 145 @env = @envs.keys.first46 end47 @pause_time = options[:pause_time] || 0.348 @is_headless = options[:is_headless]49 @firefox_profile_name = options[:firefox_profile] # nil means make a new one50 @firefox_path = options[:firefox_path]51 @threads = []52 @record = {} # record is a hash containing notes that the "user" needs to keep, like the document number he just created.53 @stderr_log = File.join(Dir::pwd, 'features', 'stderr', Time.now.strftime("%Y.%m.%d-%H.%M.%S")) # This was largely (entirely?) for Selenium 1...54 @log = Logger.new 'debug_log'55 file_outputter = FileOutputter.new 'file', :filename => File.join(Dir::pwd, 'features', 'logs', Time.now.strftime("%Y.%m.%d-%H.%M.%S"))56 @log.outputters = file_outputter57 @log.level = DEBUG58 end59 # An extrnsion of Selenium::WebDriver's find_element. It receives the same `method` and `selector`60 # arguments, and receives a third, optional argument: an options hash.61 #62 # By default, it will pass `method` and `selector` on to Selenium::WebDriver's63 # `find_element`, retrying 4 more times whenever Selenium::WebDriver throws an64 # `InvalidSelectorError`. By default, it will raise if a `NoSuchElementError`, or a65 # `TimeOutError` is raised. If you pass in `:no_raise => true`, then it will return `nil` on66 # these exceptions, rather than retry or raise.67 def find_element(method, selector, options={})68 retries = 469 sleep 0.1 # based on http://groups.google.com/group/ruby-capybara/browse_thread/thread/5e182835a8293def fixes "NS_ERROR_ILLEGAL_VALUE"70 begin71 @driver.find_element(method, selector)72 rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError => e73 return nil if options[:no_raise]74 raise e75 rescue Selenium::WebDriver::Error::InvalidSelectorError => e76 raise e if retries == 077 @log.warn "Caught a Selenium::WebDriver::Error::InvalidSelectorError: #{e}"78 @log.warn " Retrying..."79 pause 280 retries -= 181 retry82 end83 end84 # Hide a visual vertical tab inside a document's layout. Accepts the "name" of the85 # tab. Find the name of the tab by looking up the `title` of the `input` that is the86 # close button. The title is everything after the word "close."87 def hide_tab(name)88 @log.debug " hide_tab: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(:xpath, \"//input[@title='close #{name}']\")..."89 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)90 wait.until { driver.find_element(:xpath, "//input[@title='close #{name}']") }91 @driver.find_element(:xpath, "//input[@title='close #{name}']").click92 pause93 end94 # Show a visual vertical tab inside a document's layout. Accepts the "name" of the95 # tab. Find the name of the tab by looking up the `title` of the `input` that is the96 # open button. The title is everything after the word "open."97 def show_tab(name)98 @log.debug " show_tab: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(:xpath, \"//input[@title='open #{name}']\")..."99 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)100 wait.until { driver.find_element(:xpath, "//input[@title='open #{name}']") }101 @driver.find_element(:xpath, "//input[@title='open #{name}']").click102 pause103 end104 # Switch to the default tab/window/frame, and backdoor login as `user`105 def backdoor_as(user)106 switch_to.default_content107 retries = 2108 begin109 @log.debug " backdoor_as: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(:xpath, \"//*[@name='backdoorId']\")..."110 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)111 wait.until { driver.find_element(:xpath, "//*[@name='backdoorId']") }112 rescue Selenium::WebDriver::Error::TimeOutError => error113 raise e if retries == 0114 @log.debug " backdoor_as: Page is likely boned. Navigating back home..."115 @driver.navigate.to (@envs[@env]['url'] || "https://kf-#{@env}.mosaic.arizona.edu/kfs-#{@env}")116 retries -= 1117 pause118 retry119 end120 set_field("//*[@name='backdoorId']", user)121 @driver.find_element(:css, 'input[value=login]').click122 @driver.switch_to.default_content123 @driver.find_element(*main_menu_link)124 end125 # Check the field that is expressed with `selectors` (the first one that is found).126 # `selectors` is typically an Array returned by `ApproximationsFactory`, but it could be127 # hand-generated.128 def check_approximate_field(selectors)129 timeout = DEFAULT_TIMEOUT130 selectors.each do |selector|131 begin132 return check(:xpath, selector, {:timeout => timeout})133 rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError134 timeout = 0.5135 # Try the next selector136 end137 end138 @log.error "Failed to check approximate field. Selectors are:\n#{selectors.join("\n") }"139 raise Selenium::WebDriver::Error::NoSuchElementError140 end141 # Uncheck the field that is expressed with `selectors` (the first one that is found).142 # `selectors` is typically an Array returned by `ApproximationsFactory`, but it could be143 # hand-generated.144 def uncheck_approximate_field(selectors)145 selectors.each do |selector|146 begin147 return uncheck(:xpath, selector)148 rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError149 # Try the next selector150 end151 end152 @log.error "Failed to uncheck approximate field. Selectors are:\n#{selectors.join("\n") }"153 raise Selenium::WebDriver::Error::NoSuchElementError154 end155 def check(method, locator, options={})156 timeout = options[:timeout] || DEFAULT_TIMEOUT157 @log.debug " check: Waiting up to #{timeout} seconds to find_element(#{method}, #{locator})..."158 wait = Selenium::WebDriver::Wait.new(:timeout => timeout)159 wait.until { driver.find_element(method, locator) }160 element = driver.find_element(method, locator)161 element.click unless element.selected?162 pause163 end164 def uncheck(method, locator)165 @log.debug " uncheck: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(#{method}, #{locator})..."166 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)167 wait.until { driver.find_element(method, locator) }168 element = driver.find_element(method, locator)169 element.click if element.selected?170 pause171 end172 def click_and_wait(method, locator, options = {})173 @log.debug " Start click_and_wait(#{method.inspect}, #{locator.inspect}, #{options.inspect})"174 timeout = options[:timeout] || DEFAULT_TIMEOUT175 @log.debug " click_and_wait: Waiting up to #{timeout} seconds to find_element(#{method}, #{locator})..."176 wait = Selenium::WebDriver::Wait.new(:timeout => timeout)177 wait.until { driver.find_element(method, locator) }178 dont_stdout! do179 @driver.find_element(method, locator).click180 end181 pause182 end183 def click_approximate_and_wait(locators)184 timeout = DEFAULT_TIMEOUT185 locators.each do |locator|186 begin187 click_and_wait(:xpath, locator, {:timeout => timeout})188 return189 rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError190 timeout = 0.2191 # Try the next selector192 end193 end194 raise Selenium::WebDriver::Error::NoSuchElementError195 end196 # Close all windows that have a current url of "about:blank". Must follow this with a call to197 # `#switch_to, so that you know what window you're on.198 def close_blank_windows199 @driver.window_handles.each do |handle|200 @driver.switch_to.window(handle)201 @driver.close if @driver.current_url == 'about:blank'202 end203 end204 # Temporarily redirects all stdout to `@stderr_log`205 def dont_stdout!206 orig_stdout = $stdout207 $stdout = File.open(@stderr_log, 'a')208 yield if block_given?209 $stdout = orig_stdout # restore stdout210 end211 # Enlargens the text of an element, using `method` and `locator`, by changing the `font-size`212 # in the style to be `3em`. It uses the following Javascript:213 #214 # hlt = function(c) { c.style.fontSize='3em'; }; return hlt(arguments[0]);215 def enlargen(method, locator)216 @log.debug " enlargen: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(#{method}, #{locator})..."217 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)218 wait.until { find_element(method, locator) }219 element = find_element(method, locator)220 execute_script("hlt = function(c) { c.style.fontSize='3em'; }; return hlt(arguments[0]);", element)221 end222 def get_xpath(method, locator)223 @log.debug " wait_for: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(#{method}, #{locator})..."224 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)225 wait.until { find_element(method, locator) }226 element = find_element(method, locator)227 xpath = execute_script("gPt=function(c){if(c.id!==''){return'id(\"'+c.id+'\")'}if(c===document.body){return c.tagName}var a=0;var e=c.parentNode.childNodes;for(var b=0;b<e.length;b++){var d=e[b];if(d===c){return gPt(c.parentNode)+'/'+c.tagName+'['+(a+1)+']'}if(d.nodeType===1&&d.tagName===c.tagName){a++}}};return gPt(arguments[0]);", element)228 # That line used to end with: return gPt(arguments[0]).toLowerCase();229 end230 def highlight(method, locator, ancestors=0)231 @log.debug " highlight: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(#{method}, #{locator})..."232 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)233 wait.until { find_element(method, locator) }234 element = find_element(method, locator)235 execute_script("hlt = function(c) { c.style.border='solid 1px rgb(255, 16, 16)'; }; return hlt(arguments[0]);", element)236 parents = ""237 red = 255238 ancestors.times do239 parents << ".parentNode"240 red -= (12*8 / ancestors)241 execute_script("hlt = function(c) { c#{parents}.style.border='solid 1px rgb(#{red}, 0, 0)'; }; return hlt(arguments[0]);", element)242 end243 end244 def is_text_present(text, xpath='//*')245 begin246 @driver.find_element(:xpath, "#{xpath}[contains(text(),'"+text+"')]")247 true248 rescue Selenium::WebDriver::Error::NoSuchElementError249 @log.error "Could not find: @driver.find_element(:xpath, \"#{xpath}[contains(text(),'"+text+"')]\")"250 @log.error @driver.find_element(:xpath, xpath).inspect251 false252 end253 end254 # "Maximize" the current window using Selenium's `manage.window.resize_to`. This script255 # does not use the window manager's "maximize" capability, but rather resizes the window.256 # By default, it positions the window 64 pixels below and to the right of the top left257 # corner, and sizes the window to be 128 pixels smaller both vretically and horizontally258 # than the available space.259 def maximize_ish(x = 64, y = 64, w = -128, h = -128)260 if is_headless261 x = 0; y = 0; w = -2; h = -2262 end263 width = w264 height = h265 width = "window.screen.availWidth - #{-w}" if w <= 0266 height = "window.screen.availHeight - #{-h}" if h <= 0267 if is_headless268 @driver.manage.window.position= Selenium::WebDriver::Point.new(0,0)269 max_width, max_height = @driver.execute_script("return [window.screen.availWidth, window.screen.availHeight];")270 @driver.manage.window.resize_to(max_width, max_height)271 else272 @driver.manage.window.position= Selenium::WebDriver::Point.new(40,30)273 max_width, max_height = @driver.execute_script("return [window.screen.availWidth, window.screen.availHeight];")274 @driver.manage.window.resize_to(max_width-90, max_height-100)275 end276 @driver.execute_script %[277 if (window.screen) {278 window.moveTo(#{x}, #{y});279 window.resizeTo(#{width}, #{height});280 };281 ]282 end283 def mk_screenshot_dir(base)284 @screenshot_dir = File.join(base, Time.now.strftime("%Y-%m-%d.%H"))285 return if Dir::exists? @screenshot_dir286 Dir::mkdir(@screenshot_dir)287 end288 # Pause for `@pause_time` by default, or for `time` seconds289 def pause(time = nil)290 @log.debug " breathing..."291 sleep (time or @pause_time)292 end293 # Select a frame by its `id`294 def select_frame(id)295 @driver.switch_to().frame(id)296 pause297 end298 def record_kfs_version299 @driver.find_element(:id, "build").text =~ /(3.0-(?:\d+)) \(Oracle9i\)/300 kfs_version = "%-7s" % $1301 #@driver.save_screenshot("#{@screen_shot_dir}/main_#{@env}.png")302 begin303 ChunkyPNG # will raise if library not included, fail back to normal screenshot in the 'rescue'304 screen_string_in_base64 = @driver.screenshot_as(:base64)305 @threads << Thread.new do306 screen_string = Base64.decode64(screen_string_in_base64)307 png_canvas = ChunkyPNG::Canvas.from_string(screen_string)308 png_canvas = png_canvas.crop 0, 0, 900, 240309 png_canvas = png_canvas.resample 450, 120310 png_canvas.to_image.save("public/images/cropped_#{@env}.png", :fast_rgba)311 end312 rescue NameError313 #@driver.save_screenshot("#{@screen_shot_dir}/cropped_#{@env}.png")314 end315 end316 # Take a screenshot, and save it to `@screenshot_dir` by the name `#{name}.png`317 def screenshot(name)318 @driver.save_screenshot(File.join(@screenshot_dir, "#{name}.png"))319 end320 def login_via_webauth321 @driver.find_element(*main_menu_link).click322 sleep 1323 @driver.find_element(:id, 'username').send_keys(@username)324 @driver.find_element(:id, 'password').send_keys(@password)325 @driver.find_element(:css, '#fm1 .btn-submit').click326 sleep 1327 # Check if we logged in successfully328 begin329 status = @driver.find_element(:id, 'status')330 if is_text_present("status") == "You entered an invalid NetID or password."331 raise WebauthAuthenticationError.new332 elsif is_text_present("status") == "Password is a required field."333 raise WebauthAuthenticationError.new334 end335 rescue Selenium::WebDriver::Error::NoSuchElementError336 return337 end338 end339 def run_in_envs(envs = @envs)340 envs.each do |env, properties|341 begin342 @env = env343 start_session344 @driver.navigate.to "/kfs-#{@env}/portal.jsp"345 login_via_webauth346 yield347 rescue Selenium::WebDriver::Error::NoSuchElementError => err348 1349 rescue WebauthAuthenticationError350 raise351 rescue StandardError => err352 1353 ensure354 @threads.each { |t| t.join }355 @driver.quit356 end357 end358 rescue WebauthAuthenticationError => err359 1360 end361 def get_approximate_field(selectors)362 timeout = DEFAULT_TIMEOUT363 selectors.each do |selector|364 begin365 return get_field(selector, {:timeout => timeout})366 rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError367 timeout = 0.2368 # Try the next selector369 end370 end371 puts "Failed to get approximate field. Selectors are:\n#{selectors.join("\n") }"372 raise Selenium::WebDriver::Error::NoSuchElementError373 end374 def get_field(selector, options={})375 timeout = options[:timeout] || DEFAULT_TIMEOUT376 @log.debug " get_field: Waiting up to #{timeout} seconds to find_element(:xpath, #{selector})..."377 wait = Selenium::WebDriver::Wait.new(:timeout => timeout)378 wait.until { driver.find_element(:xpath, selector) }379 element = @driver.find_element(:xpath, selector)380 @driver.execute_script("return document.evaluate(\"#{selector}\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value;", nil)381 end382 # Deselect all `<option>s` within a `<select>`, suppressing any `UnsupportedOperationError`383 # that Selenium may throw384 def safe_deselect_all(el)385 el.deselect_all386 rescue Selenium::WebDriver::Error::UnsupportedOperationError387 end388 def set_approximate_field(selectors, value=nil)389 timeout = 2390 selectors.each do |selector|391 begin392 set_field(selector, value)393 return394 rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::TimeOutError395 sleep timeout396 timeout = 0.2397 # Try the next selector398 end399 end400 @log.error "Failed to set approximate field. Selectors are:"401 selectors.each { |s| @log.error " #{s}" }402 raise Selenium::WebDriver::Error::NoSuchElementError403 end404 def set_field(id, value=nil)405 @log.debug " Start set_field(#{id.inspect}, #{value.inspect})"406 if id =~ /@value=/ # I am praying I only use value for radio buttons...407 node_name = 'radio'408 locator = id409 elsif id =~ /^\/\// or id =~ /^id\(".+"\)/410 node_name = nil411 dont_stdout! do412 begin413 node = @driver.find_element(:xpath, id)414 node_name = node.tag_name.downcase415 rescue Selenium::WebDriver::Error::NoSuchElementError416 end417 end418 locator = id419 elsif id =~ /^.+=.+ .+=.+$/420 node_name = 'radio'421 locator = id422 else423 @log.debug " set_field: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(:id, #{id})..."424 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)425 wait.until { driver.find_element(:id, id) }426 node = @driver.find_element(:id, id)427 node_name = node.tag_name.downcase428 locator = "//*[@id='#{id}']"429 end430 case node_name431 when 'input'432 @log.debug " set_field: node_name is #{node_name.inspect}"433 @log.debug " set_field: locator is #{locator.inspect}"434 # Make the field empty first435 # REPLACE WITH CLEAR436 if not locator['"'] # @TODO UGLY UGLY workaround for now. If an xpath has double quotes in it... then I can't check if it's empty just yet.437 unless get_field(locator).empty?438 @driver.execute_script("return document.evaluate(\"#{locator}\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value = '';", nil)439 end440 else441 @log.warn " set_field: locator (#{locator.inspect}) has a \" in it, so... I couldn't check if the input was empty. Good luck!"442 end443 @driver.find_element(:xpath, locator).send_keys(value)444 when 'select'445 @log.debug " set_field: Waiting up to #{DEFAULT_TIMEOUT} seconds to find_element(:xpath, #{locator})..."446 wait = Selenium::WebDriver::Wait.new(:timeout => DEFAULT_TIMEOUT)447 wait.until { driver.find_element(:xpath, locator) }448 select = Selenium::WebDriver::Support::Select.new(@driver.find_element(:xpath, locator))449 #select.click450 #pause451 #option = select.find_elements( :tag_name => 'option' ).find do |option|452 # option.text == value453 #end454 #if option.nil?455 # puts "Error: Could not find an <option> with text: '#{value}'"456 # raise Selenium::WebDriver::Error::NoSuchElementError457 #end458 #option.click459 safe_deselect_all(select)460 select.select_by(:text, value)461 when 'radio'462 @driver.find_element(:xpath, locator).click463 else464 @driver.find_element(:xpath, locator).send_keys(value)465 end466 pause467 end468 def start_session469 @download_dir = File.join(Dir::pwd, 'features', 'downloads')470 Dir::mkdir(@download_dir) unless Dir::exists? @download_dir471 if @firefox_profile_name472 @profile = Selenium::WebDriver::Firefox::Profile.from_name @firefox_profile_name473 else474 @profile = Selenium::WebDriver::Firefox::Profile.new475 end476 @profile['browser.download.dir'] = @download_dir477 @profile['browser.download.folderList'] = 2478 @profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf"479 @profile['browser.link.open_newwindow'] = 3480 if @firefox_path...

Full Screen

Full Screen

w3c_actions_test.rb

Source:w3c_actions_test.rb Github

copy

Full Screen

...60 el = @driver.find_element(:id, 'io.appium.android.apis:id/button_toggle')61 assert_equal 'OFF', el.text62 @driver.action.click(el).perform63 assert_equal 'ON', el.text64 # double tap action with pause65 action_builder = @driver.action66 input = action_builder.pointer_inputs[0]67 action_builder68 .move_to(el)69 .pointer_down(:left)70 .pause(input, 0.05) # seconds71 .pointer_up(:left)72 .pause(input, 0.05) # seconds73 .pointer_down(:left)74 .pause(input, 0.05) # seconds75 .pointer_up(:left)76 .perform77 assert_equal 'ON', el.text78 if @@core.automation_name == :espresso79 # Skip in espresso, since espresso brings the target element in the view on recyclerview even it is out of the view80 else81 error = assert_raises do82 @driver.action.double_click(el).perform83 end84 assert [::Selenium::WebDriver::Error::UnknownError,85 ::Selenium::WebDriver::Error::InvalidArgumentError].include? error.class86 end87 end88 def test_actions_with_many_down_up89 skip_as_appium_version '1.8.0'90 el = @@core.wait { @driver.find_element(:accessibility_id, 'Views') }91 @driver.action.click_and_hold(el).release.perform92 el = @@core.wait { @driver.find_element(:accessibility_id, 'Custom') }93 rect1 = el.rect.dup94 if @@core.automation_name == :espresso95 _espresso_do_actions_with_many_down_up el, rect196 else97 _uiautomator2_do_actions_with_many_down_up el, rect198 end99 end100 def _espresso_do_actions_with_many_down_up(element, rect)101 @driver102 .action103 .move_to(element)104 .pointer_down(:left) # should insert pause105 .pointer_down(:left)106 .pointer_down(:left)107 .move_to_location(0, rect.y - rect.height)108 .release109 .release110 .perform111 end112 def _uiautomator2_do_actions_with_many_down_up(element, rect)113 error = assert_raises do114 action_builder = @driver.action115 input = action_builder.pointer_inputs[0]116 @driver117 .action118 .move_to(element)119 .pointer_down(:left) # should insert pause120 .pause(input, 0.06) # seconds121 .pointer_down(:left)122 .pause(input, 0.06) # seconds123 .pointer_down(:left)124 .pause(input, 0.06) # seconds125 .move_to_location(0, rect.y - rect.height)126 .release127 .release128 .perform129 end130 assert [::Selenium::WebDriver::Error::UnknownError,131 ::Selenium::WebDriver::Error::InvalidArgumentError].include? error.class132 end133 def test_multiple_actions134 skip_as_appium_version '1.8.0'135 # https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/actions.md136 f1 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger1')137 f1.create_pointer_move(duration: 1, x: 200, y: 500,138 origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)139 f1.create_pointer_down(:left)140 f1.create_pause(0.5)141 f1.create_pointer_move(duration: 1, x: 200, y: 200,142 origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)143 f1.create_pointer_up(:left)144 f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')145 f2.create_pointer_move(duration: 1, x: 200, y: 520,146 origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)147 f2.create_pointer_down(:left)148 f2.create_pause(0.5)149 f2.create_pointer_move(duration: 1, x: 200, y: 800,150 origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)151 f2.create_pointer_up(:left)152 @@core.wait { @driver.perform_actions [f1, f2] }153 end154 end155 end156end157# rubocop:enable Style/ClassVars...

Full Screen

Full Screen

action_pauser.rb

Source:action_pauser.rb Github

copy

Full Screen

1# frozen_string_literal: true2module ActionPauser3 def initialize(mouse, keyboard)4 super5 @devices[:pauser] = Pauser.new6 end7 def pause(duration)8 @actions << [:pauser, :pause, [duration]]9 self10 end11 class Pauser12 def pause(duration)13 sleep duration14 end15 end16 private_constant :Pauser17end18if defined?(::Selenium::WebDriver::VERSION) && (::Selenium::WebDriver::VERSION.to_f < 4) &&19 defined?(::Selenium::WebDriver::ActionBuilder)20 ::Selenium::WebDriver::ActionBuilder.prepend(ActionPauser)21end...

Full Screen

Full Screen

pause

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "Selenium WebDriver"4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys "Selenium WebDriver"6driver.find_element(:name, 'btnG').click7driver.find_element(:name, 'q').send_keys "Selenium WebDriver"8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys "Selenium WebDriver"10driver.find_element(:name, 'btnG').click11driver.find_element(:name, 'q').send_keys "Selenium WebDriver"

Full Screen

Full Screen

pause

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "Selenium WebDriver"4driver.find_element(:name, 'btnG').click5wait = Selenium::WebDriver::Wait.new(:timeout => 10)6element = wait.until {driver.find_element(:class, 'r')}7driver.find_element(:name, 'q').send_keys "Selenium WebDriver"8driver.find_element(:name, 'btnG').click9wait = Selenium::WebDriver::Wait.new(:timeout => 10)10element = wait.until {driver.find_element(:class, 'r')}11driver.find_element(:name, 'q').send_keys "Selenium WebDriver"12driver.find_element(:name, 'btnG').click13wait = Selenium::WebDriver::Wait.new(:timeout => 10)14element = wait.until {driver.find_element(:class, 'r')}15driver.find_element(:name, 'q').send_keys "Selenium WebDriver"16driver.find_element(:name, 'btnG').click17wait = Selenium::WebDriver::Wait.new(:timeout => 10)18element = wait.until {driver.find_element(:class, 'r')}

Full Screen

Full Screen

pause

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'4driver.find_element(:name, 'btnG').click5wait = Selenium::WebDriver::Wait.new(:timeout => seconds)6element = wait.until { driver.find_element(:name, 'q') }

Full Screen

Full Screen

pause

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys("selenium webdriver")2driver.find_element(:name, 'btnG').click3driver.find_element(:link_text, 'Selenium - Web Browser Automation').click4driver.find_element(:name, 'q').send_keys("selenium webdriver")5driver.find_element(:name, 'btnG').click6driver.find_element(:link_text, 'Selenium - Web Browser Automation').click7driver.find_element(:name, 'q').send_keys("selenium webdriver")8driver.find_element(:name, 'btnG').click9driver.find_element(:link_text, 'Selenium - Web Browser Automation').click10driver.find_element(:name, 'q').send_keys("selenium webdriver")11driver.find_element(:name, 'btnG').click12driver.find_element(:link_text, 'Selenium - Web Browser Automation').click

Full Screen

Full Screen

pause

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, "q").send_keys "Selenium WebDriver"2driver.find_element(:name, "btnG").click3driver.find_element(:link_text, "Selenium - Web Browser Automation").click4driver.find_element(:link_text, "Downloads").click5driver.find_element(:link_text, "Ruby").click6driver.find_element(:link_text, "Selenium Ruby Bindings").click7driver.find_element(:link_text, "Downloads").click8driver.find_element(:link_text, "Ruby").click9driver.find_element(:link_text, "Selenium Ruby Bindings").click10driver.find_element(:link_text, "Downloads").click11driver.find_element(:link_text, "Ruby").click12driver.find_element(:link_text, "Selenium Ruby Bindings").click13driver.find_element(:link_text, "Downloads").click14driver.find_element(:link_text, "Ruby").click15driver.find_element(:link_text, "Selenium Ruby Bindings").click16driver.find_element(:link_text, "Downloads").click17driver.find_element(:link_text, "Ruby").click18driver.find_element(:link_text, "Selenium Ruby Bindings").click19driver.find_element(:link_text, "Downloads").click20driver.find_element(:link_text,

Full Screen

Full Screen

pause

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(name: 'q')2wait = Selenium::WebDriver::Wait.new(:timeout => 53driver.find_element(:name, 'q').send_keys 'Selenium WebDriver'4driver.find_element(:name, 'btnG').click5wait = Selenium::WebDriver::Wait.new(:timeout => seconds)6element = wait.until { driver.find_element(:name, 'q') }

Full Screen

Full Screen

pause

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, "q").send_keys "Selenium WebDriver"2driver.find_element(:name, "btnG").click3driver.find_element(:link_text, "Selenium - Web Browser Automation").click4driver.find_element(:link_text, "Downloads").click5driver.find_element(:link_text, "Ruby").click6driver.find_element(:link_text, "Selenium Ruby Bindings").click7driver.find_element(:link_text, "Downloads").click8driver.find_element(:link_text, "Ruby").click9driver.find_element(:link_text, "Selenium Ruby Bindings").click10driver.find_element(:link_text, "Downloads").click11driver.find_element(:link_text, "Ruby").click12driver.find_element(:link_text, "Selenium Ruby Bindings").click13driver.find_element(:link_text, "Downloads").click14driver.find_element(:link_text, "Ruby").click15driver.find_element(:link_text, "Selenium Ruby Bindings").click16driver.find_element(:link_text, "Downloads").click17driver.find_element(:link_text, "Ruby").click18driver.find_element(:link_text, "Selenium Ruby Bindings").click19driver.find_element(:link_text, "Downloads").click20driver.find_element(:link_text,

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 Selenium 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