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

Sae*_*eeK 4 ruby cucumber capybara site-prism selenium-webdriver

您能否帮助打印在Web浏览器中生成的控制台日志,以了解Cucumber Capybara Test Automation中的任何错误?我正在使用PhantomJS webdriver如下:

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

我想捕获Browser JS控制台日志并在我需要自动执行时打印它

Tho*_*ole 12

既然你正在使用硒,你可以试试

page.driver.browser.manage.logs.get("browser")
Run Code Online (Sandbox Code Playgroud)

注意:我从来没有尝试过使用PhantomJS作为浏览器