【问题标题】:Show the page while testing with PhantomJS through Selenium通过 Selenium 使用 PhantomJS 进行测试时显示页面
【发布时间】:2014-09-09 20:38:28
【问题描述】:

我正在使用 Selenium 和 PhantomJS 测试我的 Django 应用程序。我正在调试一个失败的测试。有没有办法让无头 PhantomJS 突然像真正的浏览器一样在屏幕上显示,以便我可以轻松调试问题?

【问题讨论】:

  • 您可能想看看这里:phantomjs.org/troubleshooting.html。但是不,你不能打开 PhantomJS。我相信你知道,它是一个无头浏览器,我不相信他们在 .exe 中提供了一个头
  • 把 PhantomJS 换成 Firefox 怎么样?
  • 这不一定是你要求的,但我经常发现我最好的调试是通过将整个页面 html 打印到 bash,使用类似 print(self.driver.find_element_by_tage_name('html')

标签: python django selenium-webdriver phantomjs


【解决方案1】:

虽然无法打开浏览器,但您可以在故障点截屏。这将帮助您了解测试失败的原因和位置。 http://phantomjs.org/screen-capture.html

【讨论】:

  • 效果很好。我使用此代码:PIL.Image.open(io.BytesIO(browser.get_screenshot_as_png())).show() 立即在调试器中查看屏幕截图。
猜你喜欢
  • 2019-12-05
  • 2014-06-01
  • 2013-05-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-18
  • 2015-07-31
  • 1970-01-01
  • 2014-08-20
相关资源
最近更新 更多