rspec - 当我在 rspec 测试中使用 Watir.default_timeout 时,它似乎不起作用
问题描述
我需要延长@page.run_asset上的等待时间,因为完成该过程可能需要超过 30 秒的时间。所以我找到了 Watir.default_time 并将其添加到我的代码中。当我运行测试时,它仍然失败并显示与以前相同的错误:
失败/错误:@page.run_asset Selenium::WebDriver::Error::ScriptTimeOutError:脚本超时:30 秒内未收到结果
it 'expects table action to succeed' do
Watir.default_timeout = 180
@page.debug_asset(table_name)
@page.select_sample(sample)
@page.run_asset
expect(@page.return_to_input_element.present?).to be true
end
我尝试实现以下代码并显示相同的错误。
it 'expects table action to succeed' do
wait = Selenium::WebDriver::Wait.new(timeout: 150)
@page.debug_asset(table_name)
@page.run_asset
field_displayed = wait.until {
@asset_debugger_page.return_to_input_element.present? }
expect(@page.return_to_input_element.present?).to be true
end
我环顾四周,似乎找不到一个好的答案。任何帮助,将不胜感激。
谢谢
解决方案
Watir 超时时间是 Watir 将等待元素出现或变为存在的时间,而不是等待页面加载、脚本执行或网络读取的时间。您想在功能中设置脚本超时。
这是在 Watir 中增加脚本超时的方法:
browser = Watir::Browser.new(:chrome, timeouts: {script: 60000})
推荐阅读
- javascript - 开玩笑 - ReferenceError: __DEV__ is not defined (React Native)
- c# - 如何在增量数据之前获取关系数据?
- lua - PANIC:调用 Lua API 时出现不受保护的错误(未定义符号:lua_gettop)
- javascript - 用户在 iOS 14.6 Safari 中单击失败后,speechSynthesis.speak() 调用 > 1000 毫秒
- bash - Linux排序命令不适用于字符串中的连字符和冒号
- python - pad_packed_sequence 如何在 pytorch 中工作?
- sql - 如何在一个时间范围内而不是在一个时间范围内选择
- json - 提取 JSON 字符串内容的替代方法
- mongodb - Spring Repository,为最大值创建手动覆盖查询
- sql - 在sql中使用case语句进行分箱