简体   繁体   English

如何使用Cucumber Ruby Automation打印浏览器控制台日志?

[英]How to Print Browser console logs using Cucumber Ruby Automation?

Can you please help on printing the console logs generate in web browser for any errors in Cucumber Capybara Test Automation? 您能否帮助打印在Web浏览器中生成的控制台日志,以了解Cucumber Capybara Test Automation中的任何错误? I am using PhantomJS webdriver as below: 我正在使用PhantomJS webdriver如下:

Capybara::Selenium::Driver.new(app, :browser => :phantomjs, desired_capabilities: { 'phantomjs.cli.args' => ['--ignore-ssl-errors=yes'] Capybara :: Selenium :: Driver.new(app,:browser =>:phantomjs,desired_capabilities:{'phantomjs.cli.args'=> ['--ignore-ssl-errors = yes']

I want to capture Browser JS console logs and print it while i need on automation execution 我想捕获Browser JS控制台日志并在我需要自动执行时打印它

Since you're using selenium you can try 既然你正在使用硒,你可以试试

page.driver.browser.manage.logs.get("browser")

Note: I've never tried it with PhantomJS as the browser 注意:我从来没有尝试过使用PhantomJS作为浏览器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM