gpt4 book ai didi

Selenium 不检测页面加载(Ruby)

转载 作者:行者123 更新时间:2023-12-01 06:40:24 27 4
gpt4 key购买 nike

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

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

08:49:43.888 INFO - 命令请求: session 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

最佳答案

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

当我去http://google.com我注意到提交搜索只会在 url 中添加 #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(丑我知道)

关于Selenium 不检测页面加载(Ruby),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11111462/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com