我做了一个测试配置,并行执行3次相同的测试。 这是某种负载测试,但有一点我在Selenium Grid的节点配置中并没有遗漏。 Hub命令:
java -jar“c:\ selenium-2.53.0 \ selenium-server-standalone-2.53.0.jar”-port 4444 -role hub -nodeTimeout 1000
节点命令:
java -jar“C:\ selenium-2.53.0 \ selenium-server-standalone-2.53.0.jar”-role node -hub http://localhost:4444/grid/register -browser browserName = firefox,maxInstances = 3,maxSession = 3 -port 5555
这是我的第一个问题,当我设置maxInstances和maxSession时,我认为这将允许我在节点上执行3个firefo浏览器。但即使我为maxInstances和maxSession设置了1,我仍然可以在运行脚本的同时运行3个浏览器。我想我的配置使用错误的方式...... Display of my console Grid
为了并行运行测试,我使用了TestNG的parellel配置,这里是我的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="tests">
<test name="Test0">
<parameter name="node" value="http://192.168.117.135:5555/wd/hub"/>
<parameter name="fullName" value="UserFullName0"/>
<parameter name="firstName" value="UserFirstName"/>
<parameter name="name" value ="UserName"/>
<parameter name="init" value ="init"/>
<parameter name="login" value ="UserLogin"/>
<parameter name="civility" value="civility"/>
<parameter name="forcePasswordChange" value ="true"/>
<parameter name="passwordControlModel" value ="pwdModel"/>
<parameter name="backUpMail" value ="backUpMail@email.com"/>
<parameter name="language" value ="fr"/>
<parameter name="externalUser" value ="true"/>
<parameter name="service" value ="service"/>
<parameter name="company" value ="company"/>
<parameter name="emailCompany" value ="emailCompany@memail.com"/>
<parameter name="contributorTest1" value ="contributor"/>
<parameter name="lockedByAdministration" value ="false"/>
<parameter name="multisessions" value ="false"/>
<parameter name="invisibleAccount" value ="false"/>
<parameter name="isAlive" value ="true"/>
<parameter name="expirationDate" value ="false"/>
<parameter name="role" value ="role"/>
<parameter name="autorizedConnection" value ="55"/>
<parameter name="authentificationPolicy" value ="LOCAL"/>
<classes>
<class name="selenium.test.UserSaveTest"/>
</classes>
</test> <!-- Test -->
<test name="Test1">
<parameter name="node" value="http://192.168.117.135:5555/wd/hub"/>
<parameter name="fullName" value="UserFullName1"/>
<parameter name="firstName" value="UserFirstName"/>
<parameter name="name" value ="UserName"/>
<parameter name="init" value ="init"/>
<parameter name="login" value ="UserLogin"/>
<parameter name="civility" value="civility"/>
<parameter name="forcePasswordChange" value ="true"/>
<parameter name="passwordControlModel" value ="pwdModel"/>
<parameter name="backUpMail" value ="backUpMail@email.com"/>
<parameter name="language" value ="fr"/>
<parameter name="externalUser" value ="true"/>
<parameter name="service" value ="service"/>
<parameter name="company" value ="company"/>
<parameter name="emailCompany" value ="emailCompany@memail.com"/>
<parameter name="contributorTest1" value ="contributor"/>
<parameter name="lockedByAdministration" value ="false"/>
<parameter name="multisessions" value ="false"/>
<parameter name="invisibleAccount" value ="false"/>
<parameter name="isAlive" value ="true"/>
<parameter name="expirationDate" value ="false"/>
<parameter name="role" value ="role"/>
<parameter name="autorizedConnection" value ="55"/>
<parameter name="authentificationPolicy" value ="LOCAL"/>
<classes>
<class name="selenium.test.UserSaveTest"/>
</classes>
</test> <!-- Test -->
<test name="Test2">
<parameter name="node" value="http://192.168.117.135:5555/wd/hub"/>
<parameter name="fullName" value="UserFullName2"/>
<parameter name="firstName" value="UserFirstName"/>
<parameter name="name" value ="UserName"/>
<parameter name="init" value ="init"/>
<parameter name="login" value ="UserLogin"/>
<parameter name="civility" value="civility"/>
<parameter name="forcePasswordChange" value ="true"/>
<parameter name="passwordControlModel" value ="pwdModel"/>
<parameter name="backUpMail" value ="backUpMail@email.com"/>
<parameter name="language" value ="fr"/>
<parameter name="externalUser" value ="true"/>
<parameter name="service" value ="service"/>
<parameter name="company" value ="company"/>
<parameter name="emailCompany" value ="emailCompany@memail.com"/>
<parameter name="contributorTest1" value ="contributor"/>
<parameter name="lockedByAdministration" value ="false"/>
<parameter name="multisessions" value ="false"/>
<parameter name="invisibleAccount" value ="false"/>
<parameter name="isAlive" value ="true"/>
<parameter name="expirationDate" value ="false"/>
<parameter name="role" value ="role"/>
<parameter name="autorizedConnection" value ="55"/>
<parameter name="authentificationPolicy" value ="LOCAL"/>
<classes>
<class name="selenium.test.UserSaveTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
与java相关的脚本:
public class UserSaveTest {
@Parameters("node")
//@Test(invocationCount = 1)
@Test(invocationCount = 1, threadPoolSize=1)
public void checkUserFields(String node) throws InterruptedException, MalformedURLException {
um.initWebDriver(node);
um.logIn("root", "pass");
um.initSave();
um.save();
um.logOut();
um.logIn("root", "pass");
um.initCheck();
User user =(User) um.getEntity();
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div[2]/div/div[2]/div/div[2]/div/div/div/textarea", user.getFullName()), user.getFullName());
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div/div[2]/div/div[2]/div[2]/div/div/div/input", user.getFirstName()), user.getFirstName());
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div/div[2]/div/div[2]/div[3]/div/div/div/input",user.getName()),user.getName());
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div/div[2]/div/div[2]/div[4]/div/div/div/input",user.getInit()),user.getInit());
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div/div[2]/div/div[2]/div[5]/div/div/div/input",user.getCivility()), user.getCivility());
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div/div[2]/div/div[2]/div[7]/div[2]/div/div/div/div/input",user.getLogin()), user.getLogin());
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div/div[2]/div/div[2]/div[7]/div[2]/div[3]/div/div/textarea",user.getPassWordControlModel()), user.getPassWordControlModel());
Assert.assertEquals(um.findTextAndCompare("//div[2]/div[2]/div/div[2]/div/div[2]/div[7]/div[2]/div[4]/div/div/input","password_Test1"), "password_Test1");
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
Calendar calendar = Calendar.getInstance();
String todaysDate = dateFormat.format(calendar.getTime());
Assert.assertEquals(um.findTextAndCompare("//div[3]/div/div/input", todaysDate), todaysDate);
Assert.assertEquals(um.findTextAndCompare("//div[10]/div[2]/div[4]/div/div/div/input", user.getAutorizedConnection()),user.getAutorizedConnection());
Assert.assertEquals(um.findAndCheckMenu("//div[5]/div/div/button", user.getAuthentificationPolicy()),user.getAuthentificationPolicy());
//fin des champs textuels
//champs radio
Assert.assertTrue(um.findAndCheckRadio("//div[2]/div[2]/div/div/label", "//div[2]/div/div[2]/label", false));
Assert.assertTrue(um.findAndCheckRadio("//div[3]/div/div/label", "//div[3]/div/div[2]/label", true));
Assert.assertTrue(um.findAndCheckRadio("//div[9]/div[2]/div/div/div/label", "//div[9]/div[2]/div/div/div[2]/label", false));
Assert.assertTrue(um.findAndCheckRadio("//div[9]/div[2]/div[2]/div/div/label", "//div[9]/div[2]/div[2]/div/div[2]/label", false));
Assert.assertTrue(um.findAndCheckRadio("//div[9]/div[2]/div[3]/div/div/label", "//div[9]/div[2]/div[3]/div/div[2]/label", false));
Assert.assertTrue(um.findAndCheckRadio("//div[4]/div/div/label", "//div[4]/div/div[2]/label", true));
//fin champs radio
um.deleteUser();
um.close();
}
//Suppression de l'user et fermeture du driver
@AfterTest
public void finishTheTest() {
um.close();
}
}
Whan我检查节点地址,我看到我运行的所有会话,并且有超过3. scprit执行得很好,但我想知道为什么它不工作时。 如果我可以在我的节点的maxSession和maxInstances设置为1的同时执行浏览器的3个实例,那么这些实例有什么用? 感谢
答案 0 :(得分:1)
鲍勃, maxSession -
为了确保在启动节点时正确读取配置,您是否可以利用JSON配置文件来指定它并使用它来启动节点?我猜测,当您按照自己的方式传递配置时,可能无法正确读取配置。
要创建节点配置文件,您可以创建一个类似于下面的
的json文件{
"capabilities":
[
{
"browserName": "firefox",
"maxInstances": 1
}
],
"configuration":
{
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444"
}
}
从here
借来的样本然后将节点启动命令改为如下所示
java -jar "C:\selenium-2.53.0\selenium-server-standalone-2.53.0.jar" -role node -hub http://localhost:4444/grid/register -nodeConfig C:\selenium-2.53.0\nodeConfig.json -port 5555
这里
C:\硒-2.53.0 \ nodeConfig.json
将包含我之前粘贴的json内容。
以这种方式启动节点后,我认为您应该发生的事情。
答案 1 :(得分:0)
maxSession是一个命令行标志,而不是一个功能,所以改为运行你的节点:
java -jar "C:\selenium-2.53.0\selenium-server-standalone-2.53.0.jar" -role node -hub http://localhost:4444/grid/register -browser browserName=firefox,maxInstances=1 -port 5555 -maxSession 1