简体   繁体   English

在Selenium测试自动化中加载可执行驱动程序

[英]Load driver executable in Selenium test automation

I am running automation test with Selenium, Maven (my code is written in Java) on a remote machine. 我正在使用Selenium,Maven(我的代码是用Java编写)在远程计算机上运行自动化测试。

On my virtual machine (Ip: 10.31.142.13) (the one I am running the browsers on): I have folder C:\\Selenium with contains selinum server jar file, and IE driver and chrome driver. 在我的虚拟机上(Ip:10.31.142.13) (正在运行我的浏览器的虚拟机上):我有C:\\ Selenium文件夹,其中包含selinum服务器jar文件以及IE驱动程序和chrome驱动程序。 I run this command: 我运行以下命令:

java -jar selenium-server-standalone-2.44.0.jar -mode hub

On my local machine (the one I run the tests from): I run the test with firefox on virtual machine, and it was successful. 在我的本地计算机 (运行测试的计算机)上:我在虚拟机上使用firefox运行了测试,并且成功。 But my problem is with IE driver executable file: I don't know how to give the path to folder on my virtual machine. 但是我的问题是IE驱动程序可执行文件:我不知道如何给虚拟机上的文件夹提供路径。 This is my code: 这是我的代码:

@Test  //this test runs successfully
public void firefoxViewerTest() throws MalformedURLException
{
    System.out.println("Firefox test starting ...");
    DesiredCapabilities capability = DesiredCapabilities.firefox();

    driver = new RemoteWebDriver(new URL("http://10.31.142.13:4444/wd/hub"), capability);        
    driver.manage().deleteAllCookies();
    driverWait = new WebDriverWait(driver, 60);

    baseActions();
    System.out.println("Firefox test pass");
}

@Test
public void ieViewerTest() throws MalformedURLException
{
    System.out.println("IE test starting ...");
    //I want to use path to C:\Selenium on my virtual machine here
    System.setProperty("webdriver.ie.driver", "\\Selenium\\IEDriverServer.exe");
    DesiredCapabilities capability = DesiredCapabilities.internetExplorer();

    driver = new RemoteWebDriver(new URL("http://10.31.142.13:4444/wd/hub"), capability);
    driver.manage().deleteAllCookies();
    driverWait = new WebDriverWait(driver, 60);

    baseActions();
    System.out.println("IE test pass");
}

Any thoughts appreciated. 任何想法表示赞赏。 Thanks 谢谢

Thanks @PriyanshuShekhar for the suggestion. 感谢@PriyanshuShekhar的建议。 I run the command with -Dwebdriver in front, on the node, and I can run all web browsers IE; 我在节点的前面使用-Dwebdriver运行命令,并且可以运行所有Web浏览器IE; FF, Chrome without setting property. FF,Chrome没有设置属性。

java -Dwebdriver.ie.driver=C:\Selenium\IEDriverServer.exe -jar selenium-server-standalone-2.44.0.jar -mode hub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM