Showing posts with label WebDriver. Show all posts
Showing posts with label WebDriver. Show all posts

Wednesday, 21 March 2012

GEB - browser automation solution

Geb is a browser automation solution.
It brings together the power of WebDriver, the elegance of jQuery content selection, the robustness of Page Object modelling and the expressiveness of the Groovy language.
Read more on the project home page: http://www.gebish.org/

RemoteWebDriver

You can test UI automation tests with WebDriver for browsers that are not installed on your machine. Use RemoteWebDriver.
Read more on: http://code.google.com/p/selenium/wiki/RemoteWebDriverServer

Saturday, 3 December 2011

Testing asynchronous actions using WebDriver (f.e. AJAX)

Here is a code snippet showing how to test ajax actions using WebDriver. You can use WebDriverWait.until method defining condition that checks if web page's structure has changed. In the WebDriverWait constructor you have to define timeout in seconds. If this time passes then method ends with an exception.
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition() {
  public Object apply(Object input) {
      try {
        WebElement elem = driver.findElement(By.id(changedElem));
        boolean condition = Here you can state condition
        return condition;
      } catch (StaleElementReferenceException e) {
        return false;
      }
    }
  });

Tuesday, 15 November 2011

Runing ChromeDriver on Linux

I decided to use WebDriver in my project. It is a next version of Selenium library used for tests. I am using Ubuntu system. In my pom.xml I needed only to add one dependency:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>2.5.0</version>
</dependency>

I have created a simple java code in my main method:

 WebDriver driver = new ChromeDriver();
 driver.get("http://google.pl");
 driver.findElement(By.name("q")).sendKeys("Selenium");
 driver.findElement(By.name("q")).submit();

My program did not manage to connect to Chrome web browser. I needed to download chromedriver from http://code.google.com/p/chromium/downloads/list and add a system property webdriver.chrome.driver with path to this file.

It did work!