Thursday, February 6, 2014

Selenium in Google Chrome

In this tutorial, we will be going through the process of using Selenium Server (previously Selenium RC Server) to make the recorded trace to be able to run in chrome.


Download Selenium IDE (firefox plugin), it is to record the actions of firefox.

Download Selenium Server (selenium-server-standalone-2.39.0.jar), and Selenium Client (selenium-java-2.39.0.zip, link is below the Selenium Client & WebDriver Language Bindings).

Selenium IDE (firefox plugin) [Record the trace from firefox]
1.       1. In firefox, go to Selenium IDE.
2.       2. Click record to record the action
3.       3. File>Export Test Case as>Java|JUnit 4|Remote Control

Selenium Server (Running of JUnit test cases exported by Selenium IDE) [Replay the trace in Google Chrome]
1.       1. Open Eclipse, Create a Java Project, Add the Java Source file in (we will fix later)
2.       2. Configure Path - Right Click on the Project on left panel, and Select Build Path>Configure Build Path, Add JUnit, and two jar files in

3.    3. Open in Google chromeIn the selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.baidu.com/");
to
selenium = new DefaultSelenium("localhost", 4444, "*googlechrome", "http://www.baidu.com/");

4. Run it - Run the java file, it should prompt the chrome, and after running, it will prompts the status of the junit test cases.

P/S: Aside from SeleniumHQ, You may wish to lookout for iMacros for chrome

https://chrome.google.com/webstore/detail/imacros-for-chrome/cplklnmnlbnpmjogncfgfijoopmnlemp/details


===Self Reference===
To Try
1.       Capture Screenshot
selenium.captureScreenshot("C:\\a.jpg");
2.       To make it slower

selenium.waitForPageToLoad("30000"); or using slow flag

1 comment: