|
Running tests against the Grid
Now that we have set up the Grid with different instances, we should have a look at how we can write tests against these Remote Controls on the Grid. We can pass in the value of the target that we can see in the grid and then run the tests. So instead of passing in *firefox you can use "firefox on linux" and then run the tests as usual.
Let's see this in action.
Time for action – writing tests against the grid
- Create a new test file.
- Populate it with a test script that accesses an item on the grid and then works against http://book.theautomatedtester.co.uk/. Your script should look similar to the following:
- import org.junit.*;
- import com.thoughtworks.selenium.*;
- public class TestExamples2 {
- Selenium selenium;
- @Before
- public void setUp(){
- selenium = new DefaultSelenium("192.168.157.153",4444,
- "Google Chrome on Linux",
- "http://book.theautomatedtester.co.uk");//
- selenium.start();
- }
- @After
- public void tearDown(){
- selenium.stop();
- }
- @Test
- public void ShouldRunTestsAgainstGoogleChromeOnLinux(){
- selenium.open("/");
- selenium.click("link=chapter2");
- }
- }
复制代码
What just happened?
We have just seen how we can write tests that can run against the Grid and then run them. When the tests are running the grid will show which Remote Control is currently in use and which grid items are currently free. We can see this in the following screenshot:
|
|