How to use start method of Selenium.WebDriver Package

Best Selenium code snippet using Selenium.WebDriver.start

IM_Suite.rb

Source:IM_Suite.rb Github

copy

Full Screen

...634mailtext = part1 + part2 + part3635# Let's put our code in safe area636=begin637begin 638 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',639 'qa_usamp', 'sampleu09!', :plain) do |smtp|640 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',641 ['nitin_kumar@persistent.co.in'])642 end643rescue Exception => e 644 print "Exception occured: " + e 645end 646sleep 2647begin 648 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',649 'qa_usamp', 'sampleu09!', :plain) do |smtp|650 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',651 ['rahul_halankar@persistent.co.in'])652 end653rescue Exception => e 654 print "Exception occured: " + e 655end 656begin 657 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',658 'qa_usamp', 'sampleu09!', :plain) do |smtp|659 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',660 ['gaurav_parrikar@persistent.co.in'])661 end662rescue Exception => e 663 print "Exception occured: " + e 664end665begin 666 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',667 'qa_usamp', 'sampleu09!', :plain) do |smtp|668 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',669 ['vipul_paikane@persistent.co.in'])670 end671rescue Exception => e 672 print "Exception occured: " + e 673end674begin 675 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',676 'qa_usamp', 'sampleu09!', :plain) do |smtp|677 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',678 ['mittal_saglani@persistent.co.in'])679 end680rescue Exception => e 681 print "Exception occured: " + e 682end683begin 684 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',685 'qa_usamp', 'sampleu09!', :plain) do |smtp|686 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',687 ['maryushka_fernandes@persistent.co.in'])688 end689rescue Exception => e 690 print "Exception occured: " + e 691end692begin 693 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',694 'qa_usamp', 'sampleu09!', :plain) do |smtp|695 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',696 ['sandesh_hurli@persistent.co.in'])697 end698rescue Exception => e 699 print "Exception occured: " + e 700end701begin 702 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',703 'qa_usamp', 'sampleu09!', :plain) do |smtp|704 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',705 ['mangesh_naik@persistent.co.in'])706 end707rescue Exception => e 708 print "Exception occured: " + e 709end710begin 711 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',712 'qa_usamp', 'sampleu09!', :plain) do |smtp|713 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',714 ['neethi_thilakan@persistent.co.in'])715 end716rescue Exception => e 717 print "Exception occured: " + e 718end719begin 720 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',721 'qa_usamp', 'sampleu09!', :plain) do |smtp|722 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',723 ['sangeeta_pai@persistent.co.in'])724 end725rescue Exception => e 726 print "Exception occured: " + e 727end728begin 729 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',730 'qa_usamp', 'sampleu09!', :plain) do |smtp|731 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',732 ['jesse@usamp.com'])733 end734rescue Exception => e 735 print "Exception occured: " + e 736end737=begin738begin 739 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',740 'qa_usamp', 'sampleu09!', :plain) do |smtp|741 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',742 ['gaurav.parrikar@gmail.com'])743 end744rescue Exception => e 745 print "Exception occured: " + e 746end747begin 748 Net::SMTP.start('relay.jangosmtp.net', 25,'relay.jangosmtp.net',749 'qa_usamp', 'sampleu09!', :plain) do |smtp|750 smtp.sendmail(mailtext, 'USAMPQA@usamp.com',751 ['usample_qa@persistent.co.in'])752 end753rescue Exception => e 754 print "Exception occured: " + e 755end756=end757Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)758=begin759Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', 'selautomationmail@gmail.com', 'selautomationmail', :login) do |smtp|760 smtp.send_message(mailtext, 'qa@gmail.com', 'usample_qa@persistent.co.in')761end762=begin763Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', 'selautomationmail@gmail.com', 'selautomationmail', :login) do |smtp|764 smtp.send_message(mailtext, 'qa@gmail.com', 'jesse@usamp.com')765end766=end767=begin768Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', 'selautomationmail@gmail.com', 'selautomationmail', :login) do |smtp|769 smtp.send_message(mailtext, 'qa@gmail.com', 'sarvesh_borkar@persistent.co.in')770end771=end772Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', 'selautomationmail@gmail.com', 'selautomationmail', :login) do |smtp|773 smtp.send_message(mailtext, 'qa@gmail.com', 'susana_quadros@persistent.co.in')774end...

Full Screen

Full Screen

selenium_driver_setup.rb

Source:selenium_driver_setup.rb Github

copy

Full Screen

...55 tries ||= 356 puts "Thread: provisioning selenium chrome ruby driver"57 driver = Selenium::WebDriver.for :chrome58 rescue StandardError => e59 puts "Thread #{THIS_ENV}\n try ##{tries}\nError attempting to start remote webdriver: #{e}"60 sleep 261 retry unless (tries -= 1).zero?62 end63 driver64 end65 def stand_alone_server_chrome_driver66 driver = nil67 3.times do |times|68 begin69 driver = Selenium::WebDriver.for(70 :remote,71 :url => 'http://' + ($selenium_config[:host_and_port] || "localhost:4444") + '/wd/hub',72 :desired_capabilities => :chrome73 )74 break75 rescue StandardError => e76 puts "Error attempting to start remote webdriver: #{e}"77 raise e if times == 278 end79 end80 driver81 end82 def ruby_firefox_driver(options)83 driver = nil84 begin85 tries ||= 386 puts "Thread: provisioning selenium ruby firefox driver"87 driver = Selenium::WebDriver.for(:firefox, options)88 rescue StandardError => e89 puts "Thread #{THIS_ENV}\n try ##{tries}\nError attempting to start remote webdriver: #{e}"90 sleep 291 retry unless (tries -= 1).zero?92 end93 driver94 end95 def stand_alone_server_firefox_driver(caps)96 driver = nil97 3.times do |times|98 begin99 driver = Selenium::WebDriver.for(100 :remote,101 :url => 'http://' + ($selenium_config[:host_and_port] || "localhost:4444") + '/wd/hub',102 :desired_capabilities => caps103 )104 break105 rescue StandardError => e106 puts "Error attempting to start remote webdriver: #{e}"107 raise e if times == 2108 end109 end110 driver111 end112 def selenium_driver;113 $selenium_driver114 end115 alias_method :driver, :selenium_driver116 def firefox_profile117 profile = Selenium::WebDriver::Firefox::Profile.new118 profile.load_no_focus_lib=(true)119 profile.native_events = true120 if $selenium_config[:firefox_profile].present?121 profile = Selenium::WebDriver::Firefox::Profile.from_name($selenium_config[:firefox_profile])122 end123 profile124 end125 def host_and_port126 if $selenium_config[:host] && $selenium_config[:port] && !$selenium_config[:host_and_port]127 $selenium_config[:host_and_port] = "#{$selenium_config[:host]}:#{$selenium_config[:port]}"128 end129 end130 def set_native_events(setting)131 driver.instance_variable_get(:@bridge).instance_variable_get(:@capabilities).instance_variable_set(:@native_events, setting)132 end133 def app_host134 "http://#{$app_host_and_port}"135 end136 def self.setup_host_and_port137 ENV['CANVAS_CDN_HOST'] = "canvas.instructure.com"138 if $selenium_config[:server_port]139 $server_port = $selenium_config[:server_port]140 $app_host_and_port = "#{SERVER_IP}:#{$server_port}"141 return $server_port142 end143 # find an available socket144 s = Socket.new(:INET, :STREAM)145 s.setsockopt(:SOCKET, :REUSEADDR, true)146 s.bind(Addrinfo.tcp(SERVER_IP, 0))147 $server_port = s.local_address.ip_port148 server_ip = if $selenium_config[:browser] == 'ie'149 # makes default URL for selenium the external IP of the box for standalone sel servers150 `curl http://instance-data/latest/meta-data/public-ipv4` # command for aws boxes gets external ip151 else152 s.local_address.ip_address153 end154 $app_host_and_port = "#{server_ip}:#{s.local_address.ip_port}"155 puts "found available port: #{$app_host_and_port}"156 return $server_port157 ensure158 s.close() if s159 end160 def self.start_webserver(webserver)161 setup_host_and_port162 case webserver163 when 'thin'164 self.start_in_process_thin_server165 when 'webrick'166 self.start_in_process_webrick_server167 else168 puts "no web server specified, defaulting to WEBrick"169 self.start_in_process_webrick_server170 end171 end172 def self.shutdown_webserver(server)173 shutdown = lambda do174 server.shutdown175 HostUrl.default_host = nil176 HostUrl.file_host = nil177 end178 at_exit { shutdown.call }179 return shutdown180 end181 def self.rack_app182 app = Rack::Builder.new do183 use Rails::Rack::Debugger unless Rails.env.test?184 run CanvasRails::Application185 end.to_app186 lambda do |env|187 nope = [503, {}, [""]]188 return nope unless allow_requests?189 # wrap request in a mutex so we can ensure it doesn't span spec190 # boundaries (see clear_requests!)191 result = request_mutex.synchronize { app.call(env) }192 # check if the spec just finished while we ran, and if so prevent193 # side effects like redirects (and thus moar requests)194 if allow_requests?195 result196 else197 # make sure we clean up the body of requests we throw away198 # https://github.com/rack/rack/issues/658#issuecomment-38476120199 result.last.close if result.last.respond_to?(:close)200 nope201 end202 end203 end204 class << self205 def disallow_requests!206 # ensure the current in-flight request (if any, AJAX or otherwise)207 # finishes up its work, and prevent any subsequent requests before the208 # next spec gets underway. otherwise race conditions can cause sadness209 # with our shared conn and transactional fixtures (e.g. special210 # accounts and their caching)211 @allow_requests = false212 request_mutex.synchronize { }213 end214 def allow_requests!215 @allow_requests = true216 end217 def allow_requests?218 @allow_requests219 end220 def request_mutex221 @request_mutex ||= Mutex.new222 end223 end224 def self.start_in_process_thin_server225 require File.expand_path(File.dirname(__FILE__) + '/servers/thin_server')226 server = SpecFriendlyThinServer227 app = self.rack_app228 server.run(app, :BindAddress => BIND_ADDRESS, :Port => $server_port, :AccessLog => [])229 shutdown = self.shutdown_webserver(server)230 return shutdown231 end232 def self.start_in_process_webrick_server233 require File.expand_path(File.dirname(__FILE__) + '/servers/webrick_server')234 server = SpecFriendlyWEBrickServer235 app = self.rack_app236 server.run(app, :BindAddress => BIND_ADDRESS, :Port => $server_port, :AccessLog => [])237 shutdown = self.shutdown_webserver(server)238 return shutdown239 end240end...

Full Screen

Full Screen

options.rb

Source:options.rb Github

copy

Full Screen

...24 #25 # Create a new Options instance.26 #27 # @example28 # options = Selenium::WebDriver::Chrome::Options.new(args: ['start-maximized', 'user-data-dir=/tmp/temp_profile'])29 # driver = Selenium::WebDriver.for(:chrome, options: options)30 #31 # @param [Hash] opts the pre-defined options to create the Chrome::Options with32 # @option opts [Array<String>] :args List of command-line arguments to use when starting Chrome33 # @option opts [String] :binary Path to the Chrome executable to use34 # @option opts [Hash] :prefs A hash with each entry consisting of the name of the preference and its value35 # @option opts [Array<String>] :extensions A list of paths to (.crx) Chrome extensions to install on startup36 # @option opts [Hash] :options A hash for raw options37 # @option opts [Hash] :emulation A hash for raw emulation options38 #39 def initialize(**opts)40 @args = Set.new(opts.delete(:args) || [])41 @binary = opts.delete(:binary) || Chrome.path42 @prefs = opts.delete(:prefs) || {}43 @extensions = opts.delete(:extensions) || []44 @options = opts.delete(:options) || {}45 @emulation = opts.delete(:emulation) || {}46 @encoded_extensions = []47 end48 #49 # Add an extension by local path.50 #51 # @example52 # options = Selenium::WebDriver::Chrome::Options.new53 # options.add_extension('/path/to/extension.crx')54 #55 # @param [String] path The local path to the .crx file56 #57 def add_extension(path)58 raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.file?(path)59 raise Error::WebDriverError, "file was not an extension #{path.inspect}" unless File.extname(path) == '.crx'60 @extensions << path61 end62 #63 # Add an extension by Base64-encoded string.64 #65 # @example66 # options = Selenium::WebDriver::Chrome::Options.new67 # options.add_encoded_extension(encoded_string)68 #69 # @param [String] encoded The Base64-encoded string of the .crx file70 #71 def add_encoded_extension(encoded)72 @encoded_extensions << encoded73 end74 #75 # Add a command-line argument to use when starting Chrome.76 #77 # @example Start Chrome maximized78 # options = Selenium::WebDriver::Chrome::Options.new79 # options.add_argument('start-maximized')80 #81 # @param [String] arg The command-line argument to add82 #83 def add_argument(arg)84 @args << arg85 end86 #87 # Add a new option not yet handled by bindings.88 #89 # @example Leave Chrome open when chromedriver is killed90 # options = Selenium::WebDriver::Chrome::Options.new91 # options.add_option(:detach, true)92 #93 # @param [String, Symbol] name Name of the option...

Full Screen

Full Screen

startBrowser.rb

Source:startBrowser.rb Github

copy

Full Screen

1# Module for starting different browsers2module StartBrowser3 # No distinguish between android/iOs here as this is just a intermediate step before running the tests on emulators/real devices4 @user_agent = { chrome:5 {6 'Phone' => 'Mozilla/5.0(iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3',7 'Tablet' => 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'8 }9 }10 # A basic highlighting class for debugging purposes11 class HighlightAbstractTest12 def highlight(element, driver, color)13 orig_style = element.attribute("style")14 driver.execute_script("arguments[0].setAttribute(arguments[1], arguments[2])", element, "style", "border: 2px solid #{color}; color: #{color};")15 sleep 116 driver.execute_script("arguments[0].setAttribute(arguments[1], arguments[2])", element, "style", orig_style)17 end18 def call(*args)19 case args.first20 when :before_click21 #puts "Clicking #{args[1]}"22 highlight args[1], args[2], "red"23 when :before_find24 end25 end26 end27 # Start local chrome with the provided user-agent28 def self.start_chrome(app_type)29 args = ['--always-authorize-plugins', '--disable-popup-blocking']30 if ENV['PPAPI'] == "True"31 args.push('--load-extension=ppapi')32 args.push('--unlimited-storage')33 else34 args.push("--enable-npapi")35 end36 if @user_agent[:chrome].key?(app_type)37 args.push("--user-agent=#{@user_agent[:chrome][app_type]}")38 end39 if ENV['DEBUG']40 return Selenium::WebDriver.for :chrome, switches: args, listener: HighlightAbstractTest.new41 else42 return Selenium::WebDriver.for :chrome, switches: args43 end44 end45 # Start remote chrome driver with the provided user-agent46 def self.start_remote_chrome(app_type)47 args = ['--always-authorize-plugins', '--disable-popup-blocking']48 if ENV['PPAPI'] == "True"49 args.push('--load-extension=ppapi')50 args.push('--unlimited-storage')51 else52 args.push("--enable-npapi")53 end54 if @user_agent[:chrome].key?(app_type)55 args.push("--user-agent=#{@user_agent[:chrome][app_type]}")56 end57 remote_caps = Selenium::WebDriver::Remote::Capabilities.chrome('chromeOptions' => { 'args' => args })58 return Selenium::WebDriver.for :remote, url: REMOTE_WEB_DRIVER, desired_capabilities: remote_caps59 end60 # Start local ie with the provided user-agent and language61 def self.start_ie(_app_type, native)62 # native_events=false is required for some scenarios in IE otherwise clicks do not register63 caps = Selenium::WebDriver::Remote::Capabilities.ie('ie.ensureCleanSession' => true, 'ie.browserCommandLineSwitches' => 'private')64 if native65 return Selenium::WebDriver.for :ie, desired_capabilities: caps66 else67 return Selenium::WebDriver.for :ie, native_events: false, desired_capabilities: caps68 end69 end70 # Start remote ie driver71 def self.start_remote_ie72 caps = Selenium::WebDriver::Remote::Capabilities.ie('ie.ensureCleanSession' => true, 'ie.browserCommandLineSwitches' => 'private')73 Selenium::WebDriver.for :remote, url: REMOTE_WEB_DRIVER, desired_capabilities: caps74 end75 def self.firefox_profile76 default_profile = Selenium::WebDriver::Firefox::Profile.new77 default_profile.native_events = true78 default_profile["plugin.default.state"] = 279 return default_profile80 end81 # Start remote firefox driver with the provided user-agent82 # Note: Firefox should be ready to roll with Selenium 2.46 https://code.google.com/p/selenium/issues/detail?id=750683 def self.start_remote_ff84 # WARNING: Trying to run too many remote FF instances may cause issues with ephemeral ports:85 # https://code.google.com/p/selenium/wiki/ScalingWebDriver86 caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => self.firefox_profile)87 Selenium::WebDriver.for :remote, url: REMOTE_WEB_DRIVER, desired_capabilities: caps88 end89 # Start local firefox with provided user-agent90 def self.start_firefox91 # See https://code.google.com/p/selenium/issues/detail?id=555492 # version 21 of firefox must be used93 Selenium::WebDriver.for :firefox, profile: self.firefox_profile94 end95end...

Full Screen

Full Screen

sharedWebDriver.rb

Source:sharedWebDriver.rb Github

copy

Full Screen

...12 when "ui"13 Selenium::WebDriver::Chrome.driver_path=tconfigObj["DRIVER_PATH"]14 options = Selenium::WebDriver::Chrome::Options.new15 options = enable_mobile_device(options, tconfigObj)16 options.add_argument('start-maximized')17 @driver = Selenium::WebDriver.for(:chrome, options: options)18 when "headless-chrome"19 Selenium::WebDriver::Chrome.driver_path=tconfigObj["DRIVER_PATH"]20 options = Selenium::WebDriver::Chrome::Options.new21 options.add_argument('--headless')22 options = enable_mobile_device(options, tconfigObj)23 options.add_argument('start-maximized')24 @driver = Selenium::WebDriver.for(:chrome, options: options)25 when "headless-cancary"26 Selenium::WebDriver::Chrome.driver_path=tconfigObj["DRIVER_PATH"]27 caps = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: {28 binary: "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary", 29 args: [ "--headless" ]})30 @driver = Selenium::WebDriver.for(:chrome, desired_capabilities: caps)31 when "browserstack"32 tconfigObjBrowserStack = load_config(Dir.pwd + "/configuration/user_browserstack.json")33 caps = Selenium::WebDriver::Remote::Capabilities.new34 caps["os"] = tconfigObjBrowserStack["BROWSERSTACK_OS"]35 caps["os_version"] = tconfigObjBrowserStack["BROWSERSTACK_OSVERSION"]36 caps["browser"] = tconfigObjBrowserStack["BROWSERSTACK_BROWSER"]37 caps["browser_version"] = tconfigObjBrowserStack["BROWSERSTACK_BROWSERVERSION"]38 caps["resolution"] = tconfigObjBrowserStack["BROWSERSTACK_RESOLUTION"]39 caps["browserstack.local"] = tconfigObjBrowserStack["BROWSERSTACK_LOCAL"]40 caps["browserstack.selenium_version"] = tconfigObjBrowserStack["BROWSERSTACK_SELENIUMVERSION"]41 remoteHunUrl = "http://%s:%s@hub-cloud.browserstack.com/wd/hub" % [tconfigObjBrowserStack["BROWSERSTACK_USERNAME"], tconfigObjBrowserStack["BROWSERSTACK_ACCESSKEY"]]42 @driver = Selenium::WebDriver.for(:remote, :url => remoteHunUrl, :desired_capabilities => caps)43 when "hub"44 tconfigObjHub = load_config(Dir.pwd + "/configuration/user_hub.json")45 caps = Selenium::WebDriver::Remote::Capabilities.new46 caps["browserName"] = tconfigObjHub["NODE_BROWSER_NAME"]47 caps["browserVersion"] = tconfigObjHub["NODE_BROWSER_VERSION"]48 caps["platform"] = tconfigObjHub["NODE_PLATFORM"]49 caps["seleniumVersion"] = tconfigObjHub["NODE_SELENIUM_VERSION"]50 @driver = Selenium::WebDriver.for(:remote, :url => "%s/wd/hub" % [tconfigObjHub["HUB_URL"]], :desired_capabilities => caps)51 else52 Selenium::WebDriver::Chrome.driver_path=tconfigObj["DRIVER_PATH"]53 options = Selenium::WebDriver::Chrome::Options.new54 options = enable_mobile_device(options, tconfigObj)55 options.add_argument('start-maximized')56 @driver = Selenium::WebDriver.for(:chrome, options: options)57 end58 @driver.manage.window.move_to(0, 0)59 @wait = Selenium::WebDriver::Wait.new(:timeout => 30) # seconds60 @listWait = Selenium::WebDriver::Wait.new(:timeout => 120) # seconds61 @shortWait = Selenium::WebDriver::Wait.new(:timeout => 3) # seconds62 @normalWait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds63 end64 65 def get_driver()66 return @driver67 end68 69 def get_waitor() ...

Full Screen

Full Screen

example.rb

Source:example.rb Github

copy

Full Screen

...15end16# RETURNS: Unable to locate element: {"method":"css selector","selector":"#finish"} (Selenium::WebDriver::Error::NoSuchElementError)17#run do18# @driver.get 'http://the-internet.herokuapp.com/dynamic_loading/2'19# @driver.find_element(css: '#start button').click20# expect(@driver.find_element(id: 'finish').displayed?).to eql true21#end22# WORKS23run do24 @driver.get 'http://the-internet.herokuapp.com/dynamic_loading/2'25 @driver.find_element(css: '#start button').click26 Selenium::WebDriver::Wait.new(timeout: 6).until { @driver.find_element(id: 'finish').displayed? }27 expect(@driver.find_element(id: 'finish').displayed?).to eql true28end29# RETURNS: `until': timed out after 2 seconds (Selenium::WebDriver::Error::TimeOutError)30#run do31# @driver.get 'http://the-internet.herokuapp.com/dynamic_loading/2'32# @driver.find_element(css: '#start button').click33# Selenium::WebDriver::Wait.new(timeout: 2).until { @driver.find_element(id: 'finish') }34# expect(@driver.find_element(id: 'finish').displayed?).to eql true35#end36## WORKS ON BOTH37## + cleanup38def wait_for(seconds = 6)39 Selenium::WebDriver::Wait.new(:timeout => seconds).until { yield }40end41run do42 @driver.get 'http://the-internet.herokuapp.com/dynamic_loading/1'43 @driver.find_element(css: '#start button').click44 wait_for { @driver.find_element(id: 'finish').displayed? }45 expect(@driver.find_element(id: 'finish').displayed?).to eql true46end

Full Screen

Full Screen

selenium_webdriver_phantomjs_monkey_patch.rb

Source:selenium_webdriver_phantomjs_monkey_patch.rb Github

copy

Full Screen

...16 true17 end18end19##20# Don't start new PhantomJS process21#22Selenium::WebDriver::PhantomJS::Service.class_eval do23 def start(args = [])24 require 'selenium/webdriver/common'25 if @process && @process.alive?26 raise "already started: #{@uri.inspect} #{@executable.inspect}"27 end28 puts "Starting monkey-patched PhantomJS Selenium Webdriver"29 # @process = create_process(args)30 # @process.start31 socket_poller = Selenium::WebDriver::SocketPoller.new Selenium::WebDriver::Platform.localhost, @uri.port, Selenium::WebDriver::PhantomJS::Service::START_TIMEOUT32 unless socket_poller.connected?33 raise Selenium::WebDriver::Error::WebDriverError, "unable to connect to phantomjs @ #{@uri} after #{Selenium::WebDriver::PhantomJS::Service::START_TIMEOUT} seconds"34 end35 Selenium::WebDriver::Platform.exit_hook { stop } # make sure we don't leave the server running36 end37end...

Full Screen

Full Screen

background_selenium_firefox_driver.rb

Source:background_selenium_firefox_driver.rb Github

copy

Full Screen

...45 if defined?(Selenium::WebDriver::Firefox::Launcher) && Selenium::WebDriver::Platform.mac?6 # Run firefox in the background, on OS X7 Selenium::WebDriver::Firefox::Launcher.class_eval do8 def start9 assert_profile10 @binary.start_with @profile, @profile_dir, ''11 end12 end13 end14end ...

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')6driver.action.move_to(element).perform7element = driver.find_element(:name, 'q')

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = browser.find_element(:name, 'q')2element = browser.find_element(:name, 'q')3element = browser.find_element(:name, 'q')4element = browser.find_element(:name, 'q')5element = browser.find_element(:name, 'q')6element = browser.find_element(:name, 'q')7element = browser.find_element(:name, 'q')

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(name: 'q')2element = driver.find_element(name: 'q')3element = driver.find_element(name: 'q')4element = driver.find_element(name: 'q')5element = driver.find_element(name: 'q')6element = driver.find_element(name: 'q')7element = driver.find_element(name: 'q')

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')6element = driver.find_element(:name, 'q')

Full Screen

Full Screen

start

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').click

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')6element = driver.find_element(:name, 'q')

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')6element = driver.find_element(:name, 'q')

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = browser.find_element(:name, 'q')2element = browser.find_element(:name, 'q')3element = browser.find_element(:name, 'q')4element = browser.find_element(:name, 'q')5element = browser.find_element(:name, 'q')6element = browser.find_element(:name, 'q')7element = browser.find_element(:name, 'q')

Full Screen

Full Screen

start

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')6element = driver.find_element(:name, 'q')

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