Java + Selenium series of concurrent execution threads as much use cases

一、Selenium   Grid 

What is Selenium Grid?  

Selenium Grid Selenium is one of three components zoomed

Use ⼾ Selenium Grid allows simultaneous testing different browsers on different machines and systems

Two, Selenium Grid composed
hub node

Center Weighted registration information and node status, or master control node management node information of each node receives and forwards off ⼾ end (test script) request to the appropriate node node node node

Submenu node or a proxy node is responsible for registering the configuration information to the hub node (internet, browser, browser version, etc.) responsible for receiving to automatically request forwarded by hub nodes to Perform Specific Use Examples may also be used alone as the remote node YES Test Using example

Third, prepare the environment 

Test machine installed JDK, configure the environment variables

Download selenium-server-standalone-xxxjar

 

Reference links https://npm.taobao.org/mirrors/selenium

Fourth, when running a configuration 

1. Start hub 

java -jar selenium-server-standalone-3.141.59.jar -role hub -port 8888 -maxSession 10

Parameters explanation:

java -jar selenium-server-standalone-3.141.59.jar ----------运⾏jar包

-role hub ---------- with discolored when running a hub of ⻆

-port 8888 ---------- specify when running a hub of end-connector (default is 4444)

-maxSession 10 --------- treatment session is largest

To ⽅ then YES, bat script can be written to perform it

2, the hub of view when running a state 

Browser lose START http: // localhost: 8888 / grid / console, you can open hub operating status

 

 

 

3, the start node 

With chrome configuration as an example:

java -Dwebdriver.chrome.driver="chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role node -hub "http://192.168.4.4:8888/grid/register" -port 5558 -browser "browserName=chrome,maxInstances=2,version=68,platform=WINDOWS"

Parameters explanation:

Dwebdriver.chrome.driver = chromedriver.exe --------- specify the path where the drive chromeDriver (local)

-jar selenium-server-standalone-3.141.59.jar ----------- packet when running a jar

-role node ------------- node ⻆ discolored to Perform

-hub "http://192.168.1.222:8888/grid/register" ----------------- specify the address you want to link hub, this node to connect and hub communications

-port Perform end of 5558 ----------- node

-browser  browserName=chrome,maxInstances=2,version=68,platform=WINDOWS

      browserName = chrome browser when running a name of

      maxInstances = 2 ⽀ most browsers examples are shown two holder

      version = 68 browser version

      platform = WINDOWS platform name

Convert bat script is as follows:

 

 

4. Perform Script 

node node configuration instructions 

a single node may be configured node ⼀ browser, such as chrome, firefox, IE, etc.

five, YES TestNG concurrent testing 
Selenium Grid can be distributed when running a different browsers on different machines, but the effect we see perform while the string (also after ⼀ is a browser YES, then another when running a ⼀ a browser). To achieve the effect of concurrent perform to, Selenium Grid do not

We need concurrent Perform mechanism by TestNG unit testing framework brought. Concurrent execution can bring benefits ⾏:

Perform reduce the time: and ⾏ test means that multiple browsers can be while at the same time ⼀ Perform from ⽽ reduce the overall time spent on testing and ⾏ allows multiple threads to simultaneously perform it a test script / different test scripts

Concurrent test configuration TestNG 

He explained:
Parallel = Tests table displayed on the label in order to test for the ⼀ threads per unit?

thread-count = number of threads 2

Guess you like

Origin www.cnblogs.com/wanshuang/p/12634022.html