selenium-webdriver 4.0未显示异常消息

问题描述

我将Selenium与Capybara和Cucumber结合使用,在Ruby mine中针对Chrome浏览器运行自动化测试。我已经将selenium-webdriver更新为4.0.0.alpha5版本(以前的版本是3.13.1),之后我发现访问Capybary函数时发生了一些异常,当发生此错误时,我总是收到此消息:

NameError: uninitialized constant Selenium::WebDriver::Error::UnhandledError

对于文档中找不到的元素或任何有意义的原因,我希望有一些与错误相关的信息,此消息将阻止解决代码中的潜在问题。

如何避免此消息?是否需要进行任何错误配置才能正确捕获异常?

-编辑-

堆栈跟踪:

NameError: uninitialized constant Selenium::WebDriver::Error::UnhandledError
./features/step_deFinitions/dspFramework_steps/navigation.rb:314:in `assertPageTitle'
./features/step_deFinitions/dspFramework_steps/navigation.rb:293:in `/^I assert that the page's title is( not)? "([^"]*)"/'
./features/step_deFinitions/dspFramework_steps/common_steps.rb:260:in `/^I click the site logo$/'
./features/dspApps_features/DSPCommon_features/DSPCommon_Add_DebugLog_CustomWebapp.feature:23:in `Then I click the site logo'

assertPageTitle方法在此行失败

if pageFocus.has_selector?('span.highcharts-title')

解决方法

我已经通过将水豚宝石更新到当前最新版本(3.33.0)来解决此问题,在此之前,我一直在使用3.10.1版本进行测试。更新后,以前的错误不再发生,当我在测试中强行执行错误时,我从Capybara收到了正确的错误消息:

Capybara::ExpectationNotMet: expected to find css ".detailtable" within #<Capybara::Node::Element tag="div" path="/HTML/BODY[1]/DIV[1]/DIV[2]/DIV[3]/DIV[1]"> at least 1 time but there were no matches

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...