I made a test configuration to execute the same test 3 time in parallel. It's some kind of load testing but there is some point i'm not undertsanding in the configuration of the nodes of Selenium Grid. Hub command :
java -jar "c:\\selenium-2.53.0\\selenium-server-standalone-2.53.0.jar" -port 4444 -role hub -nodeTimeout 1000
Node command :
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
Here is my first problem, when i set the maxInstances and the maxSession, i thought it was what will allow me to execute 3 firefo browser on the node. But even if i put 1 for maxInstances and maxSession, i still can run the 3 browser at the same time when i run my script. I guess my configuration is used the wrong way... Display of my console Grid
To run the test in parallel i used the parellel configuration of TestNG, here my xml file :
<?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 -->
And the script in java associated :
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 i check on the node address i see all the session that i have run and there is more than 3. The scprit is well executed but i want to know why it is working when it isn't supposed to. If i can execute the 3 instances of my browser at the same time when the maxSession and the maxInstances of my nodes are setted to 1, what are the use of these ? Thanks
Bob, maxSession -
Just to ensure that your configurations are being read properly when you start the node, can you please resort to leveraging a JSON configuration file for specifying it and start the node using that ? I am guessing that perhaps the configurations aren't being read properly when you pass it the way you have.
To create a node configuration file, you can create a json file which looks like below
{
"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"
}
}
Sample borrowed from here
You then alter you node start command to something like below
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
here
C:\\selenium-2.53.0\\nodeConfig.json
would contain the json content that I have pasted earlier.
Once you start the node in this manner, I think what you expect should happen.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.