我试图通过硒网格测试运行一个测试。
这些测试以前工作,但今天,我得到这个错误:
The path to the driver executable must be set by the webdriver.ie.driver system property
这个错误没有意义,因为我的测试应该在firefox上运行。
这是位....
TESTNG
<test name="Run using Firefox 25 on Windows 7">
<parameter name="GridBrowser" value="firefox25win7"/>
<classes>
<class name="com.coursestrand_courseoverviewpanel.CourseOverviewPanelTest"/>
</classes>
</test>
上面值
的代码片段import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Configuration {
public static DesiredCapabilities setCap;
public static final String GRID_HUB_URL = "http://192.168.53.67:4444/wd/hub";
public static String SeleniumGridSetup(String gridBrowser) {
String newGridBrowser = gridBrowser;
switch (newGridBrowser) {
case "firefox25win7":
System.out.println("Firefox Version 25.0 on Windows 7");
setCap= DesiredCapabilities.firefox();
setCap.setBrowserName("firefox25win7");
setCap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
break;
}
return newGridBrowser;
}
这是我的测试
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.*;
import com.environments.Configuration;
import com.thoughtworks.twist.core.execution.TwistScenarioDataStore;
import org.openqa.selenium.firefox.*;
import org.testng.Assert;
public class CourseOverviewPanelTest {
public WebDriver browser;
public static String url;
@Autowired
private TwistScenarioDataStore scenarioStore;
@Parameters({"GridBrowser"})
public CourseOverviewPanelTest(String GridBrowser) throws Exception {
Configuration.SeleniumGridSetup(GridBrowser);
browser = new RemoteWebDriver(new URL(Configuration.GRID_HUB_URL), Configuration.setCap);
url = Configuration.getUrl();
browser.manage().window().maximize();
browser.navigate().to(url + "/course-list.html");
}
public CourseOverviewPanelTest() throws Exception {
browser = new FirefoxDriver();
browser.manage().window().maximize();
url = Configuration.getUrl();
browser.navigate().to(url + "/course-list.html");
}
// Test methods start from here for Landing page carousel
@Test
public void displayCourseTitleAndDescription() throws Exception {
final String courseTitle = browser.findElement(By.xpath("/html/body/section/section/article/ul/li[1]/h4")).getText();
Assert.assertEquals("Maths", courseTitle);
}
SELENIUM GRID NODE
java -jar selenium-server-standalone-2.39.0.jar -role webdriver -hub http://192.168.53.67:4444/grid/register -browser browserName="firefox25win7",platform=WINDOWS -port 5585
这是运行FIREFOX NODE时在GRID中创建的配置
role:webdriver
remoteHost:http://192.168.53.70:5585
hubHost:192.168.53.67
hubPort:4444
prioritizer:null
timeout:300000
throwOnCapabilityNotPresent:true
nodePolling:5000
url:http://192.168.53.70:5585
newSessionWaitTimeout:-1
proxy:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
cleanUpCycle:5000
hub:http://192.168.53.67:4444/grid/register
port:5585
browser:browserName=firefox25win7,platform=WINDOWS
browserTimeout:0
host:192.168.53.70
servlets:[]
maxSession:5
registerCycle:5000
capabilityMatcher:org.openqa.grid.internal.utils.DefaultCapabilityMatcher
register:true
当我执行测试时,在控制台中返回错误。
注意:如果我确实设置了可执行驱动程序的路径(在节点中),那么测试将在IE中运行!
进一步注意:当我运行我的chrome节点时,也会出现这个问题,它看起来像这样:
java -Dwebdriver.chrome.driver=C:/selenium-server/chromedriver.exe -jar selenium-server-standalone-2.39.0.jar -role webdriver -hub http://192.168.53.67:4444/grid/register -port 5566 -browser browserName="chromeLatestWindows7",platform=WINDOWS
疯狂的事情是,如果我改变-Dwebdriver.chrome.driver=C:/selenium-server/chromedriver.exe在上述节点-Dwebdriver.ie.driver=C:/selenium-server/chromedriver.exe然后我的测试在chrome中运行良好!
问题似乎与browsername有关。根据文档允许的值是"-browser允许的参数:browserName={android, chrome, firefox, htmlunit, internet explorer, iphone, opera}"。将firefox25win7的名称更改为firefox,它应该可以工作