Best Selenium code snippet using Selenium.WebDriver.refresh
driver.rb
Source:driver.rb
...48 end49 def visit(path)50 browser.navigate.to(path)51 end52 def refresh53 browser.navigate.refresh54 end55 def go_back56 browser.navigate.back57 end58 def go_forward59 browser.navigate.forward60 end61 def html62 browser.page_source63 end64 def title65 browser.title66 end67 def current_url...
selenium_spec_marionette.rb
Source:selenium_spec_marionette.rb
...48 when 'Capybara::Session selenium node #click should allow multiple modifiers'49 pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session)50 when /^Capybara::Session selenium node #double_click/51 pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session)52 when 'Capybara::Session selenium #refresh it reposts'53 skip 'Firefox insists on prompting without providing a way to suppress'54 when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default'55 pending "Geckodriver doesn't set a blank response currently"56 when 'Capybara::Session selenium #attach_file with multipart form should fire change once for each set of files uploaded'57 pending 'Gekcodriver appends files so we have to first call clear for multiple files which creates an extra change ' \58 'if files are already set'59 when 'Capybara::Session selenium #attach_file with multipart form should fire change once when uploading multiple files from empty'60 pending "FF < 62 doesn't support setting all files at once" if marionette_lt?(62, @session)61 end62end63RSpec.describe 'Capybara::Session with firefox' do # rubocop:disable RSpec/MultipleDescribes64 include Capybara::SpecHelper65 include_examples 'Capybara::Session', TestSessions::SeleniumMarionette, :selenium_marionette66 include_examples Capybara::RSpecMatchers, TestSessions::SeleniumMarionette, :selenium_marionette67end68RSpec.describe Capybara::Selenium::Driver do69 before do70 @driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox, options: browser_options)71 end72 describe '#quit' do73 it 'should reset browser when quit' do74 expect(@driver.browser).to be_truthy75 @driver.quit76 # access instance variable directly so we don't create a new browser instance77 expect(@driver.instance_variable_get(:@browser)).to be_nil78 end79 context 'with errors' do80 before do81 @original_browser = @driver.browser82 end83 after do84 # Ensure browser is actually quit so we don't leave hanging processe85 RSpec::Mocks.space.proxy_for(@original_browser).reset86 @original_browser.quit87 end88 it 'warns UnknownError returned during quit because the browser is probably already gone' do89 allow(@driver).to receive(:warn)90 allow(@driver.browser).to(91 receive(:quit)92 .and_raise(Selenium::WebDriver::Error::UnknownError, 'random message')93 )94 expect { @driver.quit }.not_to raise_error95 expect(@driver.instance_variable_get(:@browser)).to be_nil96 expect(@driver).to have_received(:warn).with(/random message/)97 end98 it 'ignores silenced UnknownError returned during quit because the browser is almost definitely already gone' do99 allow(@driver).to receive(:warn)100 allow(@driver.browser).to(101 receive(:quit)102 .and_raise(Selenium::WebDriver::Error::UnknownError, 'Error communicating with the remote browser')103 )104 expect { @driver.quit }.not_to raise_error105 expect(@driver.instance_variable_get(:@browser)).to be_nil106 expect(@driver).not_to have_received(:warn)107 end108 end109 end110 context 'storage' do111 describe '#reset!' do112 it 'does not clear either storage by default' do113 @session = TestSessions::SeleniumMarionette114 @session.visit('/with_js')115 @session.find(:css, '#set-storage').click116 @session.reset!117 @session.visit('/with_js')118 expect(@session.driver.browser.local_storage.keys).not_to be_empty119 expect(@session.driver.browser.session_storage.keys).not_to be_empty120 end121 it 'clears storage when set' do122 @session = Capybara::Session.new(:selenium_marionette_clear_storage, TestApp)123 @session.visit('/with_js')124 @session.find(:css, '#set-storage').click125 @session.reset!126 @session.visit('/with_js')127 expect(@session.driver.browser.local_storage.keys).to be_empty128 expect(@session.driver.browser.session_storage.keys).to be_empty129 end130 end131 end132 context '#refresh' do133 def extract_results(session)134 expect(session).to have_xpath("//pre[@id='results']")135 YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip136 end137 it 'can repost by accepting confirm' do138 @session = TestSessions::SeleniumMarionette139 @session.visit('/form')140 @session.select('Sweden', from: 'form_region')141 @session.click_button('awesome')142 sleep 1143 expect do144 @session.accept_confirm(wait: 0.1) do145 @session.refresh146 sleep 2147 end148 sleep 1149 end.to change { extract_results(@session)['post_count'] }.by(1)150 end151 end152end153RSpec.describe Capybara::Selenium::Node do154 context '#click' do155 it 'warns when attempting on a table row' do156 session = TestSessions::SeleniumMarionette157 session.visit('/tables')158 tr = session.find(:css, '#agent_table tr:first-child')159 allow(tr.base).to receive(:warn)...
neckermann_be.rb
Source:neckermann_be.rb
...39 driver.find_element(:id, "QsmListerOrFullTextSearch_/sitecore/content/eComHome/Configuration/Common/Components/Redesign/SOLR/QSM_label").click40rescue => exception41 retry_count -= 142 if retry_count > 043 driver.navigate.refresh44 retry45 else46 retval = 547 puts exception.backtrace48 puts "Died on #{url}"49 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"50 teardown(driver,screenfile,retval)51 end52ensure53 retry_count = 554end55# Click the first details button56begin57 url = driver.current_url58 driver.find_element(:css, "#QsmDetailLink_1 > span.label").click59rescue => exception60 retry_count -= 161 if retry_count > 062 driver.navigate.refresh63 retry64 else65 retval = 566 puts exception.backtrace67 puts "Died on #{url}"68 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"69 teardown(driver,screenfile,retval)70 end71ensure72 retry_count = 573end74#Click Book now75begin76 url = driver.current_url77 driver.find_element(:id, "calcbuttonspan_calc").click78rescue => exception79 retry_count -= 180 if retry_count > 081 driver.navigate.refresh82 retry83 else84 retval = 585 puts exception.backtrace86 puts "Died on #{url}"87 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"88 teardown(driver,screenfile,retval)89 end90ensure91 retry_count = 592end93#Click another Book now94begin95 url = driver.current_url96 driver.find_element(:xpath, "//span[@class='label bookNowButton']").click97rescue => exception98 retry_count -= 199 if retry_count > 0100 driver.navigate.refresh101 retry102 else103 retval = 5104 puts exception.backtrace105 puts "Died on #{url}"106 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"107 teardown(driver,screenfile,retval)108 end109ensure110 retry_count = 5111end112# Fill the passenger details113begin114 url = driver.current_url115 driver.find_element(:id => "TravellerDetails_1_gender").click116 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_gender")).select_by :value, "Male"117 driver.find_element(:id, "TravellerDetails_1_firstName").send_keys "Luke"118 driver.find_element(:id, "TravellerDetails_1_lastName").send_keys "Skywalker"119 driver.find_element(:id => "TravellerDetails_1_days").click120 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_days")).select_by :value, "13"121 driver.find_element(:id => "TravellerDetails_1_months").click122 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_months")).select_by :value, "6"123 driver.find_element(:id => "TravellerDetails_1_years").click124 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_years")).select_by :value, "1990"125 driver.find_element(:id => "TravellerDetails_2_gender").click126 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_gender")).select_by :value, "Female"127 driver.find_element(:id, "TravellerDetails_2_firstName").send_keys "Mara"128 driver.find_element(:id, "TravellerDetails_2_lastName").send_keys "Skywalker"129 driver.find_element(:id => "TravellerDetails_2_days").click130 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_days")).select_by :value, "25"131 driver.find_element(:id => "TravellerDetails_2_months").click132 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_months")).select_by :value, "4"133 driver.find_element(:id => "TravellerDetails_2_years").click134 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_years")).select_by :value, "1992"135 driver.find_element(:id, "foSubmit").click136rescue => exception137 retry_count -= 1138 if retry_count > 0139 driver.navigate.refresh140 retry141 else142 retval = 5143 puts exception.backtrace144 puts "Died on #{url}"145 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"146 teardown(driver,screenfile,retval)147 end148ensure149 retry_count = 5150end151#Click Next button152begin153 url = driver.current_url154 driver.find_element(:id, "btnNext").click155 driver.find_element(:id, "optionsandextrasInsurancePopupYesBtn").click156rescue => exception157 retry_count -= 1158 if retry_count > 0159 driver.navigate.refresh160 retry161 else162 retval = 5163 puts exception.backtrace164 puts "Died on #{url}"165 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"166 teardown(driver,screenfile,retval)167 end168ensure169 retry_count = 5170end171# Fill the passenger details (more)172begin173 url = driver.current_url174 driver.find_element(:id, "TravellerDetails_1_street").send_keys "Rokin"175 driver.find_element(:id, "TravellerDetails_1_houseNumber").send_keys "1"176 driver.find_element(:id, "TravellerDetails_1_zipCode").send_keys "1012 KT"177 driver.find_element(:id, "TravellerDetails_1_city").send_keys "Amsterdam"178 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_country")).select_by :value, "NL"179 driver.find_element(:id, "TravellerDetails_1_mobilePhoneNumber").send_keys "+31 30 2357822"180 driver.find_element(:id, "TravellerDetails_1_email1").send_keys "luke.skywalker@gmail.com"181 driver.find_element(:id, "ConfirmEmailAddress").send_keys "luke.skywalker@gmail.com"182 driver.find_element(:id, "toPaymentButton").click183rescue => exception184 retry_count -= 1185 if retry_count > 0186 driver.navigate.refresh187 retry188 else189 retval = 5190 puts exception.backtrace191 puts "Died on #{url}"192 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"193 teardown(driver,screenfile,retval)194 end195ensure196 retry_count = 5197end198puts "neckermann.be/vliegvakanties is well!"199teardown(driver,screenfile,retval)...
thomascook_be.rb
Source:thomascook_be.rb
...39 driver.find_element(:id, "QsmListerOrFullTextSearch_/sitecore/content/eComHome/Configuration/common/Components/QSM/VelocityQsmLarge_amount").click40rescue => exception41 retry_count -= 142 if retry_count > 043 driver.navigate.refresh44 retry45 else46 retval = 547 puts exception.backtrace48 puts "Died on #{url}"49 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"50 teardown(driver,screenfile,retval)51 end52ensure53 retry_count = 554end55# Click the first details button56begin57 url = driver.current_url58 driver.find_element(:css, "#QsmDetailLink_1 > span.label").click59rescue => exception60 retry_count -= 161 if retry_count > 062 driver.navigate.refresh63 retry64 else65 retval = 566 puts exception.backtrace67 puts "Died on #{url}"68 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"69 teardown(driver,screenfile,retval)70 end71ensure72 retry_count = 573end74#Click Book now75begin76 url = driver.current_url77 driver.find_element(:id, "calcbuttonspan_calc").click78rescue => exception79 retry_count -= 180 if retry_count > 081 driver.navigate.refresh82 retry83 else84 retval = 585 puts exception.backtrace86 puts "Died on #{url}"87 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"88 teardown(driver,screenfile,retval)89 end90ensure91 retry_count = 592end93#Click another Book now94begin95 url = driver.current_url96 driver.find_element(:xpath, "//span[@class='label bookNowButton']").click97rescue => exception98 retry_count -= 199 if retry_count > 0100 driver.navigate.refresh101 retry102 else103 retval = 5104 puts exception.backtrace105 puts "Died on #{url}"106 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"107 teardown(driver,screenfile,retval)108 end109ensure110 retry_count = 5111end112# Fill the passenger details113begin114 url = driver.current_url115 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_gender")).select_by :value, "Male"116 driver.find_element(:id, "TravellerDetails_1_firstName").send_keys "Luke"117 driver.find_element(:id, "TravellerDetails_1_lastName").send_keys "Skywalker"118 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_days")).select_by :text, "13"119 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_months")).select_by :text, "juni"120 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_years")).select_by :text, "1990"121 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_gender")).select_by :text, "Vrouw"122 driver.find_element(:id, "TravellerDetails_2_firstName").send_keys "Mara"123 driver.find_element(:id, "TravellerDetails_2_lastName").send_keys "Skywalker"124 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_days")).select_by :text, "25"125 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_months")).select_by :text, "apr"126 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_2_years")).select_by :text, "1992"127 driver.find_element(:id, "foSubmit").click128rescue => exception129 retry_count -= 1130 if retry_count > 0131 driver.navigate.refresh132 retry133 else134 retval = 5135 puts exception.backtrace136 puts "Died on #{url}"137 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"138 teardown(driver,screenfile,retval)139 end140ensure141 retry_count = 5142end143#Click Next button144begin145 url = driver.current_url146 driver.find_element(:id, "btnNext").click147rescue => exception148 retry_count -= 1149 if retry_count > 0150 driver.navigate.refresh151 retry152 else153 retval = 5154 puts exception.backtrace155 puts "Died on #{url}"156 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"157 teardown(driver,screenfile,retval)158 end159ensure160 retry_count = 5161end162# Fill the passenger details (more)163begin164 url = driver.current_url165 driver.find_element(:id, "TravellerDetails_1_street").send_keys "Rokin"166 driver.find_element(:id, "TravellerDetails_1_houseNumber").send_keys "1"167 driver.find_element(:id, "TravellerDetails_1_zipCode").send_keys "1012 KT"168 driver.find_element(:id, "TravellerDetails_1_city").send_keys "Amsterdam"169 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "TravellerDetails_1_country")).select_by :value, "NL"170 driver.find_element(:id, "TravellerDetails_1_mobilePhoneNumber").send_keys "+31 30 2357822"171 driver.find_element(:id, "TravellerDetails_1_email1").send_keys "luke.skywalker@gmail.com"172 driver.find_element(:id, "ConfirmEmailAddress").send_keys "luke.skywalker@gmail.com"173 driver.find_element(:id, "toPaymentButton").click174rescue => exception175 retry_count -= 1176 if retry_count > 0177 driver.navigate.refresh178 retry179 else180 retval = 5181 puts exception.backtrace182 puts "Died on #{url}"183 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"184 teardown(driver,screenfile,retval)185 end186ensure187 retry_count = 5188end189puts "thomascook.be/reizen/alles.aspx is well!"190teardown(driver,screenfile,retval)...
webdriver_handler.rb
Source:webdriver_handler.rb
...35 def link_to_event_stats_page(event_link)36 sleep 237 @logger.debug "Webdriver handler: navigating to #{event_link}"38 @driver.navigate.to event_link39 refresh_tries = 040 max_refresh_tries = 341 while scoreboard_frame_doesnt_exist?42 sleep 343 return nil if refresh_tries >= max_refresh_tries44 refresh_tries += 145 @logger.debug "Webdriver handler: refreshing page #{event_link}, try: #{refresh_tries}"46 @driver.navigate.refresh47 end48 iframe_element = @driver.find_element(id: 'scoreboard_frame')49 .find_element(tag_name: 'iframe')50 iframe_element.property('src')51 end52 def second_half_available?(detailed_page_link)53 sleep 254 @logger.debug "Webdriver handler: navigating to #{detailed_page_link}"55 @driver.navigate.to detailed_page_link56 second_half_tab_button = @driver.find_element(57 xpath: ".//li[@data-period='SECOND_HALF']"58 )59 Selenium::WebDriver::Wait.new(timeout: 3).until do60 !second_half_tab_button.attribute('class').include?('inactive')...
thomascook_com_v2.rb
Source:thomascook_com_v2.rb
...39 driver.find_element(:id, "searchBtn").click40rescue => exception41 retry_count -= 142 if retry_count > 043 driver.navigate.refresh44 retry45 else46 retval = 547 puts exception.backtrace48 puts "Died on #{url}"49 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"50 teardown(driver,screenfile,retval)51 end52ensure53 retry_count = 554end55# Click the first details button56begin57 url = driver.current_url58 driver.find_element(:xpath, "//button[@class='btn btn-success detailsBtn ng-binding']").click59rescue => exception60 retry_count -= 161 if retry_count > 062 driver.navigate.refresh63 retry64 else65 retval = 566 puts exception.backtrace67 puts "Died on #{url}"68 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"69 teardown(driver,screenfile,retval)70 end71ensure72 retry_count = 573end74#Click Book now75begin76 url = driver.current_url77 driver.find_element(:id, "bookNow").click78 driver.find_element(:id, "submit-extras").click79rescue => exception80 retry_count -= 181 if retry_count > 082 driver.navigate.refresh83 retry84 else85 retval = 586 puts exception.backtrace87 puts "Died on #{url}"88 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"89 teardown(driver,screenfile,retval)90 end91ensure92 retry_count = 593end94# Continue to signing forms95begin96 url = driver.current_url97 sleep 598 driver.find_element(:id, "submit-extras").location_once_scrolled_into_view99 driver.find_element(:id, "submit-extras").click100rescue => exception101 retry_count -= 1102 if retry_count > 0103 driver.navigate.refresh104 retry105 else106 retval = 5107 puts exception.backtrace108 puts "Died on #{url}"109 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"110 teardown(driver,screenfile,retval)111 end112ensure113 retry_count = 5114end115# Fill the passenger details116begin117 url = driver.current_url118 #sleep 1119 #driver.find_element(:id => "title").click120 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "title")).select_by :text, "Mr"121 driver.find_element(:id, "name").send_keys "Luke"122 driver.find_element(:id, "surname").send_keys "Skywalker"123 driver.find_element(:id, "email").send_keys "jediknight@gmail.com"124 driver.find_element(:id, "leadPassengerConfirmEmail").send_keys "jediknight@gmail.com"125 Postcode = driver.find_element(:id, "postCode")126 Postcode.location_once_scrolled_into_view127 Postcode.send_keys "E7 9AL"128 driver.find_element(:xpath, "//a[@class='btn btn-default get-address']").click129 sleep 5130 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "addressSelect")).select_by :text, "1 EARLHAM GROVE"131 City = driver.find_element(:id, "city")132 City.location_once_scrolled_into_view133 unless City.attribute('value').include? "LONDON"134 fail "City box does not contain LONDON"135 end136 CountryDropdown = driver.find_element(:id, "country")137 CountryDropdown.location_once_scrolled_into_view138 Option = CountryDropdown.find_element(tag_name: "option")139 unless Option.attribute('value').include? "UK"140 fail "Country box does not contain United Kingdom"141 end142 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "day")).select_by :text, "13"143 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "month")).select_by :text, "June"144 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "year")).select_by :text, "1990"145 driver.find_element(:id, "contactNumber").send_keys "020 7219 4272"146 driver.find_element(:xpath, "//a[@class='btn btn-success noArrow pax-confirm']").click147 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "title2Room1")).select_by :text, "Mrs"148 driver.find_element(:id, "name2Room1").send_keys "Mara"149 driver.find_element(:id, "surname2Room1").send_keys "Skywalker"150 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "day2Room1")).select_by :text, "25"151 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "month2Room1")).select_by :text, "April"152 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "year2Room1")).select_by :text, "1992"153 driver.find_element(:id, "paxSubmit").click154rescue => exception155 retry_count -= 1156 if retry_count > 0157 driver.navigate.refresh158 retry159 else160 retval = 5161 puts exception.backtrace162 puts "Died on #{url}"163 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"164 teardown(driver,screenfile,retval)165 end166ensure167 retry_count = 5168end169puts "UK v2 is well!"170teardown(driver,screenfile,retval)...
thomascook_nl.rb
Source:thomascook_nl.rb
...40 driver.find_element(:xpath, "//a[@onclick='PACKAGE.panel.solr.validateParty();']").click41rescue => exception42 retry_count -= 143 if retry_count > 044 driver.navigate.refresh45 retry46 else47 retval = 548 puts exception.backtrace49 puts "Died on #{url}"50 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"51 teardown(driver,screenfile,retval)52 end53ensure54 retry_count = 555end56# Click the first details button57begin58 url = driver.current_url59 driver.find_element(:xpath, "//a[@class='btn']").click60rescue => exception61 retry_count -= 162 if retry_count > 063 driver.navigate.refresh64 retry65 else66 retval = 567 puts exception.backtrace68 puts "Died on #{url}"69 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"70 teardown(driver,screenfile,retval)71 end72ensure73 retry_count = 574end75#Click Book now76begin77 url = driver.current_url78 driver.find_element(:id, "costAnchor").click79rescue => exception80 retry_count -= 181 if retry_count > 082 driver.navigate.refresh83 retry84 else85 retval = 586 puts exception.backtrace87 puts "Died on #{url}"88 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"89 teardown(driver,screenfile,retval)90 end91ensure92 retry_count = 593end94# Fill the passenger details95begin96 url = driver.current_url97 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "title_0")).select_by :text, "de heer"98 driver.find_element(:id, "firstName_0").send_keys "Luke"99 driver.find_element(:id, "lastName_0").send_keys "Skywalker"100 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "passengerFormBean.passengerListForm0.dayOB")).select_by :text, "13"101 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "passengerFormBean.passengerListForm0.monthOB")).select_by :text, "Juni"102 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "passengerFormBean.passengerListForm0.yearOB")).select_by :text, "1990"103 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "title_1")).select_by :text, "Mevrouw"104 driver.find_element(:id, "firstName_1").send_keys "Mara"105 driver.find_element(:id, "lastName_1").send_keys "Skywalker"106 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "passengerFormBean.passengerListForm1.dayOB")).select_by :text, "25"107 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "passengerFormBean.passengerListForm1.monthOB")).select_by :text, "Apr"108 Selenium::WebDriver::Support::Select.new(driver.find_element(:id => "passengerFormBean.passengerListForm1.yearOB")).select_by :text, "1992"109 driver.find_element(:id, "streetAddress").send_keys "Rokin"110 driver.find_element(:id, "houseNumber").send_keys "1"111 driver.find_element(:id, "postcode").send_keys "NL-1000"112 driver.find_element(:id, "townCity").send_keys "Amsterdam"113 driver.find_element(:id, "contactNumber").send_keys "+31 30 2357822"114 driver.find_element(:id, "email").send_keys "luke.skywalker@gmail.com"115 driver.find_element(:id, "confirmEmail").send_keys "luke.skywalker@gmail.com"116 driver.find_element(:id, "emergencyName").send_keys "Obiwan"117 driver.find_element(:id, "emergencyTelephone").send_keys "+31 30 2357822"118 driver.find_element(:xpath, "//input[@class='btn']").click119rescue => exception120 retry_count -= 1121 if retry_count > 0122 driver.navigate.refresh123 retry124 else125 retval = 5126 puts exception.backtrace127 puts "Died on #{url}"128 screenfile = "Fail_#{Time.now.strftime("%d.%m.%Y__%H'%M'%S")}.jpg"129 teardown(driver,screenfile,retval)130 end131ensure132 retry_count = 5133end134puts "thomascook.nl is well!"135teardown(driver,screenfile,retval)...
selenium_spec_edge.rb
Source:selenium_spec_edge.rb
...13skipped_tests = %i[response_headers status_code trigger modals]14$stdout.puts `#{Selenium::WebDriver::Edge.driver_path} --version` if ENV['CI']15Capybara::SpecHelper.run_specs TestSessions::SeleniumEdge, 'selenium', capybara_skip: skipped_tests do |example|16 case example.metadata[:description]17 when /#refresh it reposts$/18 skip 'Edge insists on prompting without providing a way to suppress'19 end20end21RSpec.describe 'Capybara::Session with Edge', capybara_skip: skipped_tests do22 include Capybara::SpecHelper23 include_examples 'Capybara::Session', TestSessions::SeleniumEdge, :selenium_edge24 include_examples Capybara::RSpecMatchers, TestSessions::SeleniumEdge, :selenium_edge25end...
refresh
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'btnG').click3Starting Firefox 3.6.13 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:
refresh
Using AI Code Generation
1sleep(5)2sleep(5)3sleep(5)4sleep(5)5sleep(5)6sleep(5)
refresh
Using AI Code Generation
1sleep(5)2sleep(5)3sleep(5)4sleep(5)5sleep(5)6sleep(5)
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!