【发布时间】:2015-05-14 19:57:11
【问题描述】:
我正在尝试让我的 Selenium Grid 在 Chrome 驱动程序上运行。
一开始我启动了集线器和节点: java -jar selenium-server-standalone-2.45.0.jar -role hub java -jar selenium-server-standalone-2.45.0.jar -role node -hub http://localhost:4444/grid/register
然后我开始我的测试:
public class ChromeDriverTest {
private WebDriver driver = null;
String BaseURL,NodeURL;
@Before
public void before() throws Exception{
BaseURL="http://www.google.com";
NodeURL="http://localhost:4444/wd/hub";
File file = new File("C:\\Users\\pushkaryova\\Desktop\\Nexus\\driver\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
DesiredCapabilities capa =DesiredCapabilities.chrome();
capa.setBrowserName("chrome");
capa.setPlatform(Platform.ANY);
driver=new RemoteWebDriver(new URL(NodeURL),capa);
}
@Test
public void GoogleSearch() throws Exception {
driver.get("http://www.google.com");
WebElement searchBox = driver.findElement(By.xpath("//div[3]/div/input[1]"));
hightlight(searchBox);
driver.findElement(By.xpath("//div[3]/div/input[1]")).clear();
driver.findElement(By.xpath("//div[3]/div/input[1]")).sendKeys("Test");
driver.findElement(By.xpath("//button")).click();
}
public void hightlight(WebElement webElement) throws InterruptedException {
for (int i = 0; i < 2; i++) {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(
"arguments[0].setAttribute('style', arguments[1]);",
webElement, "color: red; border: 3px solid red;");
}
}
}
并得到一个错误: org.openqa.selenium.WebDriverException:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置
我的代码有什么问题?
【问题讨论】:
-
你尝试过 webdriver wiki 的解决方案吗???
-
@SkorpEN 我尝试了很多解决方案并阅读了很多。但不幸的是,这对我没有帮助。也许您可以说明我的代码到底出了什么问题?
-
U 未设置 chrome 二进制文件的属性。首先从最简单的工作示例开始。 Yust 尝试在网格机器上运行 chrome 浏览器,然后通过 RemoteWebdriver。最后在网格机器上设置 chrom 二进制的系统属性。
-
我已将方法更改为:@Before public void before() throws Exception{ NodeURL="localhost:4444/wd/hub"; DesiredCapabilities c = DesiredCapabilities.chrome();文件 file = new File("C:\\Users\\pushkaryova\\Desktop\\Nexus\\driver\\chromedriver.exe"); System.setProperty("webdriver.chrome.driver", file.getAbsolutePath()); c.setPlatform(Platform.ANY); c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); driver=new RemoteWebDriver(new URL(NodeURL),c);它适用于 ChromeDriver,但不适用于 SeleniumGrid。
-
其他硒网格驱动程序是否正常工作???
标签: java selenium selenium-chromedriver selenium-grid2