gpt4 book ai didi

ruby -/usr/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill' : Timeout::Error (Timeout::Error)

转载 作者:数据小太阳 更新时间:2023-10-29 07:29:03 25 4
gpt4 key购买 nike

我正在使用 Capybara(Selenium 驱动程序)访问网站上的某些页面。我只需单击数组中的每个项目,然后单击返回按钮。一切顺利,但每次经过一些迭代后它都会崩溃。这是代码:

all(:xpath, '//table[@class="griglia_bordata"]//tr[td]/td/a[1]').each do |a|
a_js_functions << a[:href]
end
a_js_functions.each do |js_for_model|
puts js_for_model
page.execute_script js_for_model
find(:xpath, "//a[text()='Check availability']").click
puts find(".testo_grande_blu_B").text
puts "--------------------------------------------"
find(:xpath, "//a[text()='Back']").click
end

我有输出:

javascript:selectModel('130254') Style: RB2132 -------------------------------------------- javascript:selectModel('309257') Style: RB2140 -------------------------------------------- javascript:selectModel('68238') Style: RB3016 -------------------------------------------- javascript:selectModel('68248') Style: RB3025 -------------------------------------------- javascript:selectModel('68293') Style: RB3026 -------------------------------------------- javascript:selectModel('68320') Style: RB3044 -------------------------------------------- javascript:selectModel('68460') /usr/lib/ruby/1.9.1/net/protocol.rb:146:in rescue in rbuf_fill':
Timeout::Error (Timeout::Error) from
/usr/lib/ruby/1.9.1/net/protocol.rb:140:in
rbuf_fill' from /usr/lib/ruby/1.9.1/net/protocol.rb:122:in readuntil' from
/usr/lib/ruby/1.9.1/net/protocol.rb:132:in
readline' from /usr/lib/ruby/1.9.1/net/http.rb:2562:in read_status_line' from
/usr/lib/ruby/1.9.1/net/http.rb:2551:in
read_new' from /usr/lib/ruby/1.9.1/net/http.rb:1319:in block in transport_request'
from /usr/lib/ruby/1.9.1/net/http.rb:1316:in
catch' from /usr/lib/ruby/1.9.1/net/http.rb:1316:in transport_request' from
/usr/lib/ruby/1.9.1/net/http.rb:1293:in
request' from /usr/lib/ruby/1.9.1/net/http.rb:1286:in block in request' from
/usr/lib/ruby/1.9.1/net/http.rb:745:in
start' from /usr/lib/ruby/1.9.1/net/http.rb:1284:in request' from
/var/lib/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:82:in
response_for' from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:38:in request' from
/var/lib/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in
call' from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in raw_execute' from
/var/lib/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in
execute' from /var/lib/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:554:in find_elements_by' from
/var/lib/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/search_context.rb:62:in
find_elements' from /var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/selenium/driver.rb:52:in find' from
/var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/node/finders.rb:158:in
find_in_base' from /var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/node/finders.rb:137:in block in first' from
/var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/node/finders.rb:136:in
each' from /var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/node/finders.rb:136:in first' from
/var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/node/finders.rb:27:in
block in find' from /var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/node/base.rb:46:in wait_until' from
/var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/node/finders.rb:27:in
find' from (eval):2:in find' from
/var/lib/gems/1.9.1/gems/capybara-1.1.2/lib/capybara/dsl.rb:161:in
find' from /home/biske/workspace/ScrapingGlasses/lib/luxottica.rb:39:in block in
scrape' from
/home/biske/workspace/ScrapingGlasses/lib/luxottica.rb:36:in
each' from /home/biske/workspace/ScrapingGlasses/lib/luxottica.rb:36:in scrape' from
/home/biske/workspace/ScrapingGlasses/lib/luxottica.rb:12:in
go' from /home/biske/workspace/ScrapingGlasses/lib/luxottica.rb:48:in `'

最佳答案

我之前看到过类似的痕迹,以及它的 2 个潜在原因:

1) FakeWeb 和 WebMock 等 gems 修改了 ruby​​ 的 http.尝试删除这些 gem 以及您可能用来模拟/阻止 Web 请求的任何类似的 gem。

2) 我曾在一个真正负载过重的系统中看到过这种超时随机发生的情况。实际上,这里的问题不是测试,而是系统及其上运行的内容。可以更改 http 库使用的超时并继续测试。

为 capybara 更新:(来自 http://selenium.googlecode.com/svn/wiki/RubyBindings.wiki)

Capybara.register_driver :selenium_extended_http_timeout do |app|
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 240
Capybara::Selenium::Driver.new(app,
:browser => :firefox,
:http_client => client,
:resynchronization_timeout => 60,
:resynchronize => true)
end
Capybara.javascript_driver = :selenium_extended_http_timeout

很有可能您不需要重新同步的东西。

在这两种情况下,这都与 selenium 如何进行某些内部通信有关。 JsonWire 协议(protocol)。

关于ruby -/usr/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill' : Timeout::Error (Timeout::Error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12922029/

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