2017-02-21 68 views
0

我在继续进行并行测试之前查看确认,我尝试在同一台机器上的5个Firefox浏览器上运行硒测试用例,现在它只创建单个浏览器。在同一台机器上打开五个firefox - 硒网格

下面是我的节点创建命令。

java -Dwebdriver.firefox.marionette="/u01/driver/geckodriver" -jar selenium-server-standalone-3.0.1.jar -role webdriver -hub http://192.168.1.106:4444/grid/register -port 5566 -host 192.168.1.40 -browser browserName=firefox,version=38.0.1,maxInstances=5,platform=LINUX 

MAXINSTANCES = 5 - >这只够赚五Firefox或我需要编写线程类激活5个浏览器吗?

回答

0

另外添加maxSession=5参数。

maxInstance套最大数量的实例相同的浏览器的,但如果实例的最大数量(无论哪个浏览器)为1(maxSession=1),那么你就无法启动,甚至5种Firefox的情况下,如果你已经设置了maxInstance=5

+0

你的意思是maxInstance&maxSession只够做五个浏览器吗?如果是,我已经试过了,它也会创建单个浏览器实例。我使用maven + testng + seleniumgrid创建了我的项目。 –

+1

如果你的代码支持并行执行,maxInstance和maxSession应该使你的网格工作,我看不到你的代码以及你如何实例化和使用你的驱动实例。 – acikojevic

+0

是我的问题哥们。我不会在testng中为我的代码添加任何并行操作。我期待上面的命令会做的技巧没有改变代码,但我不知道这就是为什么我看你的确认。 –

0

maxInstances和maxSession仅仅不足以打开五个浏览器,我们需要编写用于并行测试的代码。

MAXINSTANCES = 5,maxSession = 5

如果使用TestNG的它会容易得多。下面一个是我的测试套件文件

<?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
    <suite name="Suite" parallel="tests"> 

    <test name="FirefoxTestOne"> 
    <parameter name="browser" value="firefox" /> 
     <classes> 
      <class name="example.NewTest" /> 
     </classes> 
    </test> 
    <test name="FirefoxTestTwo"> 
    <parameter name="browser" value="firefox" /> 
     <classes> 
      <class name="example.NewTest" /> 
     </classes> 
    </test> 
     <test name="FirefoxTestThree"> 
    <parameter name="browser" value="firefox" /> 
     <classes> 
      <class name="example.NewTest" /> 
     </classes> 
    </test> 
     <test name="FirefoxTestFour"> 
    <parameter name="browser" value="firefox" /> 
     <classes> 
      <class name="example.NewTest" /> 
     </classes> 
    </test> 
     <test name="FirefoxTestFive"> 
    <parameter name="browser" value="firefox" /> 
     <classes> 
      <class name="example.NewTest" /> 
     </classes> 
    </test> 

    </suite> 

在上述文件中提到我喜欢用不同的测试名称来运行我的example.NewTest类平行。当运行测试套件文件时,它将在硒网格节点中打开五个firefox,而不会发生会话冲突。

相关问题