Distinguish different Selenium Grid node

好久不见. 提交于 2019-12-01 11:36:43

问题


I'm dealing right now with following problem:

My Selenium Grid instance should connect few nodes which are in different locations and I would like to run each test in every location. How can I point to Selenium Grid that it should choose one node from each location and send test there? I tried manipulating browser name or platforms (ex. naming it firefox-pl/firefox-fr or windows-pl/windows-fr) but I received always following exception:

     Selenium::WebDriver::Error::UnknownError:
   Error forwarding the new session cannot find

and I found out that those values are not changeable.

Is there any other method to do it? I would not like to change browser or its version, because nature of those tests is to compare network responses on different locations and different browsers can change it.


回答1:


I also come across same situation and I just think of the node and did as follows.

In one folder 
  1.place the selenium-server-standalone-2.44.0.jar file and set the environment variable as well.

  2.create the hub: Type "java -jar selenium-server-standalone-2.44.0.jar -role hub -port 4444" in the text file and save it as Hub.bat and run it

  3.Create the node: Type "java -jar selenium-server-standalone-2.44.0.jar -role node -hub http://(IP Address of the parent machine which has above two files):4444/grid/register -port 8882 -browser "browserName=firefox,maxInstances=1,applicationName=two"" and put this file in another machine and run this. Now this node will be connected with the hub.

  4.If you want particular test should run in one node(client machine) then you can just specify the applicationName in the node as like in above point(3) and in setting the capabilities in the test class file as "desiredCapability.setCapability("applicationName", nodeName);". 

setting the application name in the node is hidden features in selenium. Now just test and enjoy.




回答2:


Sounds like you're looking to run tests in parallel, testng is a great tool to help you setup. Take a look at the following link

http://www.deepshiftlabs.com/sel_blog/?p=1932&lang=en-us




回答3:


When you start the node and you are specifying the capabilities, you might consider setting maxInstances. This value controls the number of concurrent instances of that browser which can be opened on that node. If you set this to 1 - you can run tests in parallel against the Grid but only one browser will open at a time on each node.

java.exe -jar selenium-server.jar -role node -browser "browserName=firefox,maxInstances=1,platform=ANY,seleniumProtocol=WebDriver"



来源:https://stackoverflow.com/questions/14646492/distinguish-different-selenium-grid-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!