如果我在同一页面上循环多次,Watir 会崩溃
Watir crashes if I loop several times on the same pages
我已经自动将一些证据上传到我与 watir 一起工作的合规内联网(我无法提供详细信息)。
我做了一些简单的事情,比如打开到该 Intranet 的 firefox 会话,而不是循环遍历我作为命令行参数传递的每个服务器。它使用表单搜索该服务器,点击它必须执行以上传证据(一个 zip 文件)。
ARGV.each do|server|
shotname = "#{download_directory}/foo_#{server}.png"
b.goto 'https://compl.intra.secret.com/index.php'
l = b.link text: 'Systems'
l.wait_until_present
l.exists?
l.click
....
....
end
只要我用很少的服务器执行脚本,CPU 就会达到 100%,但它毫无问题地到达终点,但是如果我传递大约 20 个服务器作为我的参数,ruby这个堆栈跟踪崩溃真的很糟糕
stack backtrace:: Failed to find value field (Selenium::WebDriver::Error::UnknownError)
from 0: 0x4edb3c - backtrace::backtrace::trace::hc4bd56a2f176de7e
from 1: 0x4edb72 - backtrace::capture::Backtrace::new::he3b2a15d39027c46
from 2: 0x4409a1 - webdriver::error::WebDriverError::new::h81babdd86c977032
from 3: 0x44b2c7 - geckodriver::marionette::MarionetteSession::response::ha4a2fbbdd9abe262
from 4: 0x429f1a - <webdriver::server::Dispatcher<T, U>>::run::h2119c674d7b88193
from 5: 0x4029b9 - std::sys_common::backtrace::__rust_begin_short_backtrace::h21d98a9ff86d4c25
from 6: 0x40be65 - std::panicking::try::do_call::h5cff0c9b18cfdbba
from 7: 0x5e6a6c - panic_unwind::__rust_maybe_catch_panic
from at /checkout/src/libpanic_unwind/lib.rs:99
from 8: 0x41eb22 - <F as alloc::boxed::FnBox<A>>::call_box::h413eb1d9d9f1c473
from 9: 0x5df13b - alloc::boxed::{{impl}}::call_once<(),()>
from at /checkout/src/liballoc/boxed.rs:692
from - std::sys_common::thread::start_thread
from at /checkout/src/libstd/sys_common/thread.rs:21
from - std::sys::imp::thread::{{impl}}::new::thread_start
from at /checkout/src/libstd/sys/unix/thread.rs:84
from /home/antenore/.gem/ruby/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
我的代码不太可接受,但我想知道它是否也是一个错误,您是否有任何建议来优化我所描述的循环。
我没有尝试 运行 没有无头扩展的脚本。
非常感谢!!!
系统:
Fedora release 26 (Twenty Six)
宝石used/installed:
watir (6.10.3)
watir-screenshot-stitch (0.6.5)
headless (2.3.1)
其他:
壁虎驱动程序 0.19.1
火狐 57.0.1
根据 geckdriver developers 的建议:
Support is best in Firefox 55 and greater, although generally the more
recent the Firefox version, the better the experience as they have
more bug fixes and features. Some features will only be available in
the most recent Firefox versions, and we strongly advise using the
latest Firefox Nightly with geckodriver.
使用最新的 geckdriver 版本(我的情况),最好使用最新版本的 Firefox。
这样做的主要原因,总是引用 hteir GitHub README
geckodriver is not yet feature complete. This means that it does not
yet offer full conformance with the WebDriver standard or complete
compatibility with Selenium. You can track the implementation status
of the latest Firefox Nightly on MDN. We also keep track of known
Selenium, remote protocol, and specification problems in our issue
tracker.
事实上,在我的具体情况下,更新到 Fedora 26 上可用的最新版本 Firefox 58.0.1 解决了我的问题。
因此,作为愚蠢的规则,您必须尽可能始终使用最新版本的 geckdriver 和 Pirefox,或者至少遵循每个 release notes(如果有)的建议。
感谢@Sam @JustinKo 和@FrankSchmitt 的宝贵支持。
我已经自动将一些证据上传到我与 watir 一起工作的合规内联网(我无法提供详细信息)。
我做了一些简单的事情,比如打开到该 Intranet 的 firefox 会话,而不是循环遍历我作为命令行参数传递的每个服务器。它使用表单搜索该服务器,点击它必须执行以上传证据(一个 zip 文件)。
ARGV.each do|server|
shotname = "#{download_directory}/foo_#{server}.png"
b.goto 'https://compl.intra.secret.com/index.php'
l = b.link text: 'Systems'
l.wait_until_present
l.exists?
l.click
....
....
end
只要我用很少的服务器执行脚本,CPU 就会达到 100%,但它毫无问题地到达终点,但是如果我传递大约 20 个服务器作为我的参数,ruby这个堆栈跟踪崩溃真的很糟糕
stack backtrace:: Failed to find value field (Selenium::WebDriver::Error::UnknownError)
from 0: 0x4edb3c - backtrace::backtrace::trace::hc4bd56a2f176de7e
from 1: 0x4edb72 - backtrace::capture::Backtrace::new::he3b2a15d39027c46
from 2: 0x4409a1 - webdriver::error::WebDriverError::new::h81babdd86c977032
from 3: 0x44b2c7 - geckodriver::marionette::MarionetteSession::response::ha4a2fbbdd9abe262
from 4: 0x429f1a - <webdriver::server::Dispatcher<T, U>>::run::h2119c674d7b88193
from 5: 0x4029b9 - std::sys_common::backtrace::__rust_begin_short_backtrace::h21d98a9ff86d4c25
from 6: 0x40be65 - std::panicking::try::do_call::h5cff0c9b18cfdbba
from 7: 0x5e6a6c - panic_unwind::__rust_maybe_catch_panic
from at /checkout/src/libpanic_unwind/lib.rs:99
from 8: 0x41eb22 - <F as alloc::boxed::FnBox<A>>::call_box::h413eb1d9d9f1c473
from 9: 0x5df13b - alloc::boxed::{{impl}}::call_once<(),()>
from at /checkout/src/liballoc/boxed.rs:692
from - std::sys_common::thread::start_thread
from at /checkout/src/libstd/sys_common/thread.rs:21
from - std::sys::imp::thread::{{impl}}::new::thread_start
from at /checkout/src/libstd/sys/unix/thread.rs:84
from /home/antenore/.gem/ruby/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
我的代码不太可接受,但我想知道它是否也是一个错误,您是否有任何建议来优化我所描述的循环。
我没有尝试 运行 没有无头扩展的脚本。
非常感谢!!!
系统:
Fedora release 26 (Twenty Six)
宝石used/installed:
watir (6.10.3)
watir-screenshot-stitch (0.6.5)
headless (2.3.1)
其他:
壁虎驱动程序 0.19.1 火狐 57.0.1
根据 geckdriver developers 的建议:
Support is best in Firefox 55 and greater, although generally the more recent the Firefox version, the better the experience as they have more bug fixes and features. Some features will only be available in the most recent Firefox versions, and we strongly advise using the latest Firefox Nightly with geckodriver.
使用最新的 geckdriver 版本(我的情况),最好使用最新版本的 Firefox。
这样做的主要原因,总是引用 hteir GitHub README
geckodriver is not yet feature complete. This means that it does not yet offer full conformance with the WebDriver standard or complete compatibility with Selenium. You can track the implementation status of the latest Firefox Nightly on MDN. We also keep track of known Selenium, remote protocol, and specification problems in our issue tracker.
事实上,在我的具体情况下,更新到 Fedora 26 上可用的最新版本 Firefox 58.0.1 解决了我的问题。
因此,作为愚蠢的规则,您必须尽可能始终使用最新版本的 geckdriver 和 Pirefox,或者至少遵循每个 release notes(如果有)的建议。
感谢@Sam @JustinKo 和@FrankSchmitt 的宝贵支持。