【发布时间】:2017-05-18 05:20:39
【问题描述】:
我正在使用 JAVA 和 Selenium WebDriver 编写测试自动化脚本, 我的测试在云环境(crossbrowsertesting.com)上运行。 有一个功能可以拍摄浏览器窗口的快照, 当我使用 RemoteWebDriver 时,这行代码工作正常,但需要用 WebDriver 替换它,因为无法获得 windowHandles。 但我现在收到以下错误,说明 "方法 getSessionId() 未为 WebDriver 类型定义"
snapshotHash=myTest.takeSnapshot(driver.getSessionId().toString());
//拍摄快照方法:
public String takeSnapshot(String seleniumTestId) throws UnirestException {
System.out.println("Screen Shots Taken.");
/*
* Takes a snapshot of the screen for the specified test.
* The output of this function can be used as a parameter for setDescription()
*/
HttpResponse<JsonNode> response = Unirest.post("http://crossbrowsertesting.com/api/v3/selenium/{seleniumTestId}/snapshots")
.basicAuth(username, api_key)
.routeParam("seleniumTestId", seleniumTestId)
.asJson();
// grab out the snapshot "hash" from the response
snapshotHash = (String) response.getBody().getObject().get("hash");
return snapshotHash;
}
【问题讨论】:
标签: selenium selenium-webdriver selenium-grid2