1. 本地代码使用RemoteWebDriver启动:
public class Testing { public void myTest()throws Exception { WebDriver driver = newRemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.firefox()); driver.get("http://www.google.com"); // RemoteWebDriverdoes not implement the TakesScreenshot class // if the driver doeshave the Capabilities to take a screenshot // then Augmenter willadd the TakesScreenshot methods to the instance WebDriver augmentedDriver = new Augmenter().augment(driver); File screenshot =((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE); } }
2. Remote机器上启动监听端口
java -jar selenium-server-standalone-2.46.0.jar -port 4444
3. 执行
本文详细介绍了如何使用Selenium的RemoteWebDriver进行自动化测试。通过本地代码启动RemoteWebDriver连接到远程机器,具体步骤包括配置监听端口、启动selenium-server及执行测试用例。示例代码展示了如何使用Java实现这一过程,包括截图功能的增强。
744

被折叠的 条评论
为什么被折叠?



