【问题标题】:Selenium does not detect page load (Ruby)Selenium 不检测页面加载(Ruby)
【发布时间】:2012-06-20 00:53:05
【问题描述】:

我目前正在使用 - 火狐13 - selenium-server-standalone-2.23.1.jar - 硒客户端(1.2.18) - rspec 1.2.8

即使页面已完全加载,Selenium 也会在此处停止

08:49:43.888 INFO - 命令请求:会话 2718493e6d4640eea76d6cb3ab1a6fc3 上的 waitForPageToLoad[300000, ]

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

【问题讨论】:

  • 您的脚本执行是否还有其他错误?

标签: selenium rspec


【解决方案1】:

我想知道谷歌页面是否使用了 AJAX,这会混淆页面加载事件。

当我转到http://google.com 时,我注意到提交搜索只在网址中添加了#q=selenium。

这可能会让 selenium 感到困惑。也许你可以等待页面元素而不是等待页面加载

一些搜索元素xpath(例如)/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(丑我知道)

【讨论】:

    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 2019-07-13
    • 2017-05-07
    • 2018-03-20
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多