【发布时间】:2012-10-01 21:56:29
【问题描述】:
我有 selenium-server-standalone.jar 在我的本地机器上运行,我想运行的测试在我的远程机器上编译,但我不知道如何让测试连接到将运行浏览器。任何帮助表示赞赏。
更新: 在我的本地机器上(我将运行浏览器的机器)我跑了
java -jar selenium-server-standalone-2.25.0.jar -mode hub
在我的远程机器上(我将运行测试)我跑了
java -jar selenium-server-standalone-2.25.0.jar -role webDriver -hub http://**My ip*:4444
我的代码包含以下内容:
@Before
public void setUp() throws Exception {
DesiredCapabilities capability = DesiredCapabilities.firefox();
driver = new RemoteWebDriver(new URL("http://**My ip**:4444/wd/hub"),
capability);
baseUrl = "http://phy05:8080";
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(1920, 1080));
我使用的是 Linux,我的测试是用 Java 编写的
【问题讨论】:
-
你的 selenium 测试是用什么语言编写的?
-
我不建议更改implicitWait。将其保留为默认值 0 将为您提供更典型的行为。大多数人实现 FluentWait(例如 WebDriverWait)来为您提供更长的可变等待时间。避免将其更改为“20”秒。
标签: java selenium selenium-webdriver webdriver