我的并行测试适用于Firefox和IE,但Chrome驱动程序甚至没有启动。只是想知道我出错了。我的chrome版本是:47.0.2526.111,我有最新的chrome驱动程序下载。我的代码和我的xml在下面。
@BeforeClass
public void beforeTest(String browser) {
// If the browser is Fire fox, then do this
DOMConfigurator.configure("log4j.xml");
if(browser.equalsIgnoreCase("firefox")) {
driver = new FirefoxDriver();
// If browser is IE, then do this
}else if (browser.equalsIgnoreCase("ie")) {
// Here I am setting up the path for my IEDriver
System.setProperty("webdriver.ie.driver", "C://Selenium-java-maven//workSpace//IEDriverServer.exe");
driver = new InternetExplorerDriver();
if(browser.equalsIgnoreCase("chrome")){
System.setProperty("webdriver.chrome.driver", "C://Selenium-java-maven//workSpace//chromedriver.exe");
driver = new ChromeDriver();
}
}
driver.get("http://localhost/2010A15/");
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests">
<test name="FirefoxTest">
<parameter name="browser" value="firefox" />
<classes>
<class name="utility1.ParallelLogin" />
</classes>
</test>
<test name="IETest">
<parameter name="browser" value="ie" />
<classes>
<class name="utility1.ParallelLogin" />
</classes>
</test>
<test name="chrome">
<parameter name="browser" value="chrome" />
<classes>
<class name="utility1.ParallelLogin" />
</classes>
</test>
</suite>
答案 0 :(得分:0)
我认为根据提供的脚本,如果提供浏览器为chrome,首先如果条件失败,因为它适用于firefox,然后转到else,如果,这里也失败了,因为我们正在交叉检查ie。所以没有机会导航chrome吧?
可以尝试下面的一次
if(browser.equalsIgnoreCase("firefox")) {
driver = new FirefoxDriver();
// If browser is IE, then do this
}
if (browser.equalsIgnoreCase("ie")) {
// Here I am setting up the path for my IEDriver
System.setProperty("webdriver.ie.driver", "C://Selenium-java-maven//workSpace//IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
if(browser.equalsIgnoreCase("chrome")){
System.setProperty("webdriver.chrome.driver", "C://Selenium-java-maven//workSpace//chromedriver.exe");
driver = new ChromeDriver();
}
谢谢你, 穆拉利