问题描述
我正在使用RemoteWebDriver从我的笔记本电脑(Java客户端)在远程PC上运行Selenium WebDriver测试。但是RemoteWebDriver还没有提供截屏API来直接获取远程PC的截图。谷歌搜索了很多,但发现似乎需要使用Json API直接从remoteWebDriver服务器获取它。任何人都可以给我一些关于如何做的指示?谢谢。
I am running Selenium WebDriver test on a remote PC from my laptop(java client), by using RemoteWebDriver. But RemoteWebDriver haven't provided screenshot API to directly get a screenshot of remote PC. Googled a lot but found seems need use to Json API to get it from remoteWebDriver server directly. Anyone can give me some instruction about how to do that? Thanks.
推荐答案
必须先扩充 RemoteWebDriver
才能使用截图功能。正如您已经发现的那样,尝试在没有扩充的情况下进行投射会导致异常。
The RemoteWebDriver
must be augmented before you can use the screenshot capability. As you have no doubt already found, attempting to cast without augmenting results in an exception.
WebDriver driver = new RemoteWebDriver( ... );
driver = new Augmenter().augment( driver );
( (TakesScreenshot)driver ).getScreenshotAs( ... );
这篇关于如何从RemoteWebDriver服务器而不是本地FirefoxDriver获取屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!