This is using the web backed selenium driver which will use the Selenium 1 commands. Once your old tests are working they can be converted to WebDriver type commands. Currently WebDriver does not support all browsers such as Safari so using this emulator mode might be best way to run WebDriver.
By using WebDriver you will not have to start the Selenium Server before running tests. In addition, WebDriver tests do not work by controlling the browser with Javascript. Selenium RC would always want to modify the proxy settings of the browser to enable operation. If your administrator has locked out the ability to modify proxy settings it was impossible to run tests against remote applications. Selenium 2 is a way around this. There should also be additional benefits when testing SSL enabled applications.
If you wish to run the tests using jUnit or have written your tests using the SeleneseTestCase class you must extend your test class. In addition you will have to add the old selenium-java-client-driver.jar file to the project. If you do not use SeleneseTestCase just extend jUnit TestCase.
For more information see http://seleniumhq.org/docs/03_webdriver.html.
The tests will end up looking like the code below.
package com.example.tests;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.ie.*;
import org.junit.*;
import static org.junit.Assert.*;
public class webDriverTest extends SeleneseTestCase {
WebDriver driver;
Selenium selenium;
public void setUp() {
driver = new FirefoxDriver();
selenium = new WebDriverBackedSelenium(driver,"http://www.lmnsolutions.com/");
}
public void tearDown() {
driver.close();
}
public void testUntitled() {
selenium.open("/");
selenium.click("//div[@id='topnav']/ul/li[4]/a/span");
selenium.waitForPageToLoad("30000");
assertEquals("$1200", selenium.getText("//div[@id='twocol-col2']/div[2]/h5[5]"));
}
}
I hope this helps you out in converting over to Selenium 2.
© Copyright 2012 LMN Solutions
If you have a question e-mail us or add a comment.

