- Go to Selenium HQ.
- Go to the Download section and download Selenium IDE plus Selenium RC
- Install the Selenium IDE into Firefox (I assume you have Firefox installed)
- Go to Google.
- From the Tools menu in Firefox select Selenium IDE.
- From the Add-On Preferences, change Selenium to save in Java.
- On the Google page, right click and select Open /ig
- Type Selenium in the Google search text field.
- Press TAB to move focus away from the input field.
- Right click on the search text field and select verifyValue q Selenium
- Note that verifyValue is the action, q is the locator and Selenium is the optional third value
- Click the I'm Feeling Lucky button.
- Go to the Selenium IDE and you should see everything we just did.
- Click the red dot in the upper right to stop the recording.
- From the File menu, save the file as LearningSelenium.java.
- Open Eclipse
- Create a Java Project
- Add the jar selenium-java-client-driver.jar to the project.
- Add the library junit 3.
- Right click on the project name in the Package Explorer and add new package com.example.tests.
- Import from File System, the LearningSelenium.java file we saved earlier.
- When you finish there should be an error because the class is called Untitled by default.
- Edit the file and change the class name to LearningSelenium
- In the setUp() change the http://change-this-to-the-site-you-are-testing/ to http://www.google.ca/
- If using Mac OS, change the browser string from *chrome to *safari.
- Add a public void tearDown() throws Exception which just calls super.tearDown();
- Run Firefox from the command line using firefox -P (or firefox-bin -P on UNIX/Linux machines)
- Create a new profile, call it selenium and save it in the Eclipse workspace
- Go to the command line and start the selenium server using:
- java -jar selenium-server.jar -firefoxProfileTemplate /directory/where/you/saved/firefox/profile/selenium
- But change the /directory/where/you/saved/firefox/profile/selenium to the place you saved the profile in step 25.
- Back in Eclipse, right click the class name and select Run As, JUnit Test
You are done.
2 comments:
Great write up Darrell. This helped me out alot!
I agree with Lumbee. Brilliant write up. The post about using Selenium from scratch was just as brilliant. This is the only "manual" I've been able to find online.
Thanks!
Post a Comment