显示 Capybara Javascript 错误的文件名和行号
在我的 Cucumber 步骤中,我使用 page.evaluate_script
与页面上的 Javascript 进行交互。
我最近遇到了以下错误:
this.results is null (Selenium::WebDriver::Error::UnexpectedJavascriptError)
./features/step_definitions/my_web_steps.rb:11:in `/^I select "([^"]*)" from the results list$/'
features/run_tournament.feature:24:in `And I select "Steve Smith" from the results list'
Capybara 给了我 Javascript 错误消息和 ruby 代码中的堆栈跟踪,但没有有关 Javascript 代码中发生此错误的位置的信息。
有没有办法让它显示发生 Javascript 错误的文件名和行号?
In my Cucumber steps, I'm using page.evaluate_script
to interact with Javascript on the page.
I've recently run into the following error:
this.results is null (Selenium::WebDriver::Error::UnexpectedJavascriptError)
./features/step_definitions/my_web_steps.rb:11:in `/^I select "([^"]*)" from the results list$/'
features/run_tournament.feature:24:in `And I select "Steve Smith" from the results list'
Capybara gives me Javascript error message and a stack trace in the ruby code, but no information about where in the Javascript code this error occurs.
Is there I way I can get it to show me the filename and line number where the Javascript error occurred?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
水豚 Google 群组中的这条帖子提出了一些想法,例如使用 culerity 而不是 selenium,因为 culerity 有一个选项可以引发 JS 错误并让 firefox 记录到文件。
我唯一能想到的另一件事是在selenium使用的firefox配置文件中安装firebug,然后在您知道javascript错误的地方调用“然后我睡30秒”之类的步骤(当然在您的步骤定义中定义)是然后查看 firebug 中的错误。
祝你好运!
This thread in the capybara google group has a few ideas, such as using culerity instead of selenium because culerity has an option for raising JS errors and getting firefox to log to a file.
The only other thing I can think of is to install firebug in the firefox profile that selenium uses, then calling a step like "Then I sleep for 30 seconds" (defining that in your step definitions of course) right where you know a javascript error is and then looking at the error in firebug.
Good luck!