我知道用Watir-Webdriver可以使用phantomJS,但是在我决定使用(默认)无头模式之前,我可以通过它来实际看到它在做什么吗?是否有可能在Watir-WebDriver中显示PhantomJS?
3
A
回答
0
您可以将所有请求和响应使用onResourceRequested和登录api's。我为我在casperjs中写下的刮板做了这个,它使用下面的phantomjs。 Watir-Webdriver应该为phantomjs的webPage对象提供一些钩子。
page.onResourceRequested = function(requestData, networkRequest) {
console.log('Request (#' + requestData.id + '): ' + JSON.stringify(requestData));
};
page.onResourceReceived = function(response) {
console.log('Response (#' + response.id + ', stage "' + response.stage + '"): ' + JSON.stringify(response));
};
+0
不幸的是没有这样的钩子。 – pguardiario
1
就像artjom B正在写的一样,除PhantomJS以外的其他模式都是不可能的。
因此,要么更改浏览器 - 我已通过更改CMD框中的环境变量使所有测试能够在每个浏览器中运行。
否则采取了很多的截图有: @ b.screenshot.save名“” - 你可以按照流过,即使你继续使用PhantomJS上
2
不确定的模式,但你可以试试这个:
require 'watir-webdriver'
b = Watir::Browser.new :phantomjs
b.screenshot.save 'step1.png'
b.goto "www.google.com"
b.screenshot.save 'step2.png'
b.url #"http://www.google.com/"
b.screenshot.save 'step3.png'
b.title #"Google"
b.screenshot.save 'step4.png'
你会得到输出,看起来像这样:
2
扩展其他响应,您可以在单击或将键发送到元素之前自动执行截图。
class Screenshotter < Selenium::WebDriver::Support::AbstractEventListener
def before_click(_, driver)
driver.save_screenshot("screenshot-#{Time.now.to_i}.png")
end
def before_change_value_of(_, driver)
driver.save_screenshot("screenshot-#{Time.now.to_i}.png")
end
end
browser = Watir::Browser.new(:phantomjs, listener: Screenshotter.new)
展望未来,您可以将所有截图加入到GIF中,它将像测试的实况视频一样工作。
相关问题
- 1. 是否有可能在PhantomJS
- 2. 是否有可能以显示tuleap
- 3. 是否有可能在ios中显示所有歌曲而不显示MPMediaPickerController
- 4. 是否可能显示在gtest
- 5. 是否有可能在Linux中显示排序的进度?
- 6. 当在plsql中为null时,是否有可能不显示xmlelement?
- 7. 是否有可能在Django中向管理员显示链接?
- 8. 是否有可能在Symfony2中只显示字段类型?
- 9. 是否有可能在DataGridView中显示1列?
- 10. 是否有可能在iphone中以横向模式显示UIImagePickerController?
- 11. 是否有可能在silverlight5中显示IsolatedStorage路径
- 12. 是否有可能在XSLT/XSL FO中显示运行总数?
- 13. 是否有可能在Arduino中显示编译器警告?
- 14. 是否有可能在UIWebView中显示AdSense?
- 15. 是否有可能不在数据框中显示NAs?
- 16. 是否有可能在食谱中显示图像直方图
- 17. 是否有可能不显示对话框在下载功能
- 18. .echo 5 + 5在WinDBG中显示“5 + 5”。是否有可能使其显示10?
- 19. 是否有可能让孩子显示:没有元素可见?
- 20. 是否有可能触击标题栏中显示的标题?
- 21. 是否有可能让asp:calender显示数据库中的日期?
- 22. 是否有可能在Jenkins上显示Fortify扫描结果
- 23. 是否有可能在GridView行之间显示RowCommand事件
- 24. 是否有可能显示在预览边界,但不打印
- 25. 是否有可能让dartdoc在属性上显示注释
- 26. 是否有可能在webview上显示之前预加载html
- 27. 是否有可能仅在首次推出时显示iAds
- 28. 是否有可能显示在Android的音频meassage
- 29. 是否有可能在WPF NavigationWindow上显示动画?
- 30. 是否有可能在IE标准视图中显示jsp页面,但不能在兼容视图中显示
除无头之外,没有其他的幻像模式。您可能需要使用其他浏览器:chrome,firefox,slimerjs。 –