Running Selenium IDE tests via Selenium Grid

做~自己de王妃 提交于 2020-01-04 02:34:12

问题


I should start off by saying that I am regretfully and painfully a noob. But I'm trying to change that!! I do not know any programming languages, but have managed to "make things happen" by doing enough research to get whatever job I've ever needed done done.

Anyway, I have been creating Selenium tests using the Selenium IDE and I am having a bit of trouble getting these test to run via Selenium Grid.

I have been exporting the tests as JUnit 4 (Webdriver) files. I am running the grid on a Ubuntu headless server, and my remote controls on one Windows 7 machine running IE9 and Firefox, and a Windows Vista machine running IE8 and Chrome.

My goal is to take the tests that I've exported from Selenium IDE as JUnit 4 (Webdriver) files and run them from the grid in parallel on my two Windows machines. I have edited my hosts files on my Windows machines to recognize the Ubuntu server by the name of "seleniumgrid". For example:

On the Ubuntu server terminal 1: ant launch-hub

Win7 terminal1: ant -Dport=5555 -Denvironment="IE9 on Windows" -Dhost=Win7 -DhubURL=http://seleniumgrid:4444 launch-remote-control

Win7 terminal2: ant -Dport=5555 -Denvironment="Firefox on Windows" -Dhost=Win7 -DhubURL=http://seleniumgrid:4444 launch-remote-control

Vista termina1: ant -Dport=5555 -Denvironment="IE8 on Windows" -Dhost=WinVista -DhubURL=http://seleniumgrid:4444 launch-remote-control

Vista terminal2: ant -Dport=5555 -Denvironment="Chrome on Windows" -Dhost=WinVista -DhubURL=http://seleniumgrid:4444 launch-remote-control

Now, from here, I'm trying to launch the JUnit4 (webdriver) file that I have exported from Selenium IDE to run this configuration. The name of the file is titled : Registration.java.

What do I have to do now to run the Registration.jar file? I can't seem to find any documentation that answers this question, which leads me to believe that I have a fundamental misunderstanding of how this all works...

Pardon if this question has been answered before. I have poor terminology when it comes to this stuff.

HUGE thanks for taking the time to read this, and even more for an answer if there is one.

-brandon


回答1:


There is no need to launch hub and nodes via ant. You can run them from cmd:

java -jar selenium-server-standalone-2.21.0.jar -role hub -- will run hub
java -jar selenium-server-standalone-2.21.0.jar -role node -hub http://seleniumgrid:4444/grid/register -- will run node

Default port for node is 5555, so for the second terminal you should specify port that differs from default one, e.g. 5556:

java -jar selenium-server-standalone-2.21.0.jar -role node -port 5556 -hub http://seleniumgrid:4444/grid/register

Also you should specify browser parameters for each node, e.g.:

-browser browserName=firefox,maxInstances=5,platform=WINDOWS

In your JUnit tests you should use RemoteWebDriver with DesiredCapabilities:

DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);

For parallel execution you should edit your tests additionally (sorry, don't work with jUnit, so can't help here much except of link that you can find below.)

Include JUnit class files, your class files, including your JUnit test classes, libraries your class files depend on in your classpath on Linux machine:

export CLASSPATH=$JUNIT_HOME/junit.jar:/myproject/classes:/myproject/lib/something.jar

Invoke the Junit command on Linux machine:

 java org.junit.runner.JUnitCore [test class name]

Or you can use ant instead.

I will recommend to start with hub on Linux and one node with one browser on Windows without any parallelization, so you will be sure that this part works correctly. As a next step run tests for two nodes sequentially and then try to run them in parallel.

For complete tutorials read these materials: How do I run JUnit using Ant, Activating Junit tests from Command Line, Grid2 tutorial, Parallel JUnit 4 and Selenium (three parts)



来源:https://stackoverflow.com/questions/10359586/running-selenium-ide-tests-via-selenium-grid

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