Selenium does not detect page load (Ruby)

I am currently using - firefox 13 - selenium-server-standalone-2.23.1.jar - selenium client (1.2.18) - rspec 1.2.8

Selenium stops here even if the page is fully loaded.

08: 49: 43.888 INFO - Command request: waitForPageToLoad [300000,] in session 2718493e6d4640eea76d6cb3ab1a6fc3

require 'rubygems' require "selenium/client" require "selenium/rspec/spec_helper" describe "Google Search" do attr_reader :selenium_driver alias :page :selenium_driver before(:all) do @selenium_driver = Selenium::Client::Driver.new \ :host => "localhost", :port => 4444, :browser => "*firefox", :url => "http://www.google.com", :timeout_in_second => 10 end before(:each) do selenium_driver.start_new_browser_session end # The system capture need to happen BEFORE closing the Selenium session append_after(:each) do @selenium_driver.close_current_browser_session end it "can find Selenium" do page.open "/" page.title.should eql("Google") page.type "q", "Selenium seleniumhq" page.click "btnG", :wait_for => :page page.value("q").should eql("Selenium seleniumhq") page.text?("seleniumhq.org").should be_true page.title.should eql("Selenium seleniumhq - Google Search") page.text?("seleniumhq.org").should be_true page.element?("link=Cached").should be_true end end 
+4
source share
1 answer

I wonder if the google page uses AJAX, which confuses the page load event.

When I went to http://google.com , I noticed that # q = selenium was added to the URL when submitting the search.

This is likely to be misleading to selenium. Perhaps instead of waiting for pageload, you can wait for the page element

Some xpath search elements (for example) / html / body / div [1] / div [3] / div [3] / div [6] / div [2] / div [3] / div / div [2] / div [2] / div / div / ol / div [2] / li [1] / div (ugly I know)

0
source

All Articles