Java testng测试通过selenium网格返回ie驱动程序路径错误,但测试针对firefox
我试图通过selenium网格使用testng运行测试 这些测试以前是有效的,但今天,我得到了以下错误:Java testng测试通过selenium网格返回ie驱动程序路径错误,但测试针对firefox,java,firefox,selenium,grid,testng,Java,Firefox,Selenium,Grid,Testng,我试图通过selenium网格使用testng运行测试 这些测试以前是有效的,但今天,我得到了以下错误: 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"> <para
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.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);
}
硒网格节点
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;
}
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节点时在网格中创建的配置
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
当我执行testng测试时,控制台返回错误
注意:
如果我设置了可执行驱动程序的路径(在节点中),那么测试将在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服务器/chromedriver.exe然后我的测试在chrome中运行良好 问题似乎出在浏览器名上。根据允许的值是“允许的参数-浏览器:浏览器名={android、chrome、firefox、htmlunit、internet explorer、iphone、opera}”。将firefox25win7的名称更改为firefox,它应该可以工作。能否向代码片段中添加更多代码,其余的代码是什么,在哪里调用?添加了上面我的大部分代码。