br.eti.kinoshita.selenium.util
Class Utils

java.lang.Object
  extended by br.eti.kinoshita.selenium.util.Utils

public class Utils
extends Object

Utility methods. Most of these methods were found on Internet and implemented here while Selenium latest version was 2.0b3. Probably some of them might be deprecated or will be in some near future. Hopefully Selenium API will grow and become much nicer, making most if not all, of these methods useless.

// TBD: Review which methods could be replaced/removed/enhanced.

Since:
0.1
Author:
Bruno P. Kinoshita - http://www.kinoshita.eti.br

Method Summary
static void clickAndWaitForElementAttributeChange(org.openqa.selenium.WebElement elementToClick, String attributeType, String attributeValue)
          Click on a WebElement as many times are necessary checking if some attribute value has changed
static void clickAndWaitForElementToDesappear(org.openqa.selenium.WebElement elementToClick)
          Click on some WebElement as many times are necessary checking if it desappeared
static void executeJavascript(org.openqa.selenium.WebDriver driver, String jsCommand)
          Execute a javascript command
static void executeJavascriptClick(org.openqa.selenium.WebDriver driver, String elementID)
          Execute the javascript onclick event
static void executeJavascriptClickIE(org.openqa.selenium.WebDriver driver, String elementID)
           
static com.google.common.base.Function<org.openqa.selenium.WebDriver,org.openqa.selenium.WebElement> presenceOfElement(org.openqa.selenium.By locator)
           
static com.google.common.base.Function<org.openqa.selenium.WebDriver,org.openqa.selenium.support.ui.Select> presenceOfSelectIndexAvailable(org.openqa.selenium.By locator, int index)
           
static void selectRadioButton(org.openqa.selenium.WebElement radioToClick)
          Select radio button
static void sleep(Long timeToSleep)
          Make actual thread sleep for X mili-seconds
static org.openqa.selenium.WebElement waitForAssyncContent(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by, Long timeout)
          Wait for assync content in a determined period
static void waitForSelectIndex(org.openqa.selenium.support.ui.Select select, Integer index, Long timeout)
          Wait for determined select index in a select (combo) box in a determined period
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

presenceOfElement

public static com.google.common.base.Function<org.openqa.selenium.WebDriver,org.openqa.selenium.WebElement> presenceOfElement(org.openqa.selenium.By locator)

presenceOfSelectIndexAvailable

public static com.google.common.base.Function<org.openqa.selenium.WebDriver,org.openqa.selenium.support.ui.Select> presenceOfSelectIndexAvailable(org.openqa.selenium.By locator,
                                                                                                                                                  int index)

executeJavascript

public static void executeJavascript(org.openqa.selenium.WebDriver driver,
                                     String jsCommand)
Execute a javascript command

Parameters:
driver -
jsCommand -

waitForAssyncContent

public static org.openqa.selenium.WebElement waitForAssyncContent(org.openqa.selenium.WebDriver driver,
                                                                  org.openqa.selenium.By by,
                                                                  Long timeout)
                                                           throws org.openqa.selenium.NoSuchElementException
Wait for assync content in a determined period

Parameters:
driver - Selenium web driver.
by - Selenium By expression.
timeout - Selenium time out.
Returns:
a WebElement asynchronously loaded.
Throws:
org.openqa.selenium.NoSuchElementException

waitForSelectIndex

public static void waitForSelectIndex(org.openqa.selenium.support.ui.Select select,
                                      Integer index,
                                      Long timeout)
Wait for determined select index in a select (combo) box in a determined period

Parameters:
select -
index -
timeout -

executeJavascriptClick

public static void executeJavascriptClick(org.openqa.selenium.WebDriver driver,
                                          String elementID)
Execute the javascript onclick event

Parameters:
driver -
elementID -

executeJavascriptClickIE

public static void executeJavascriptClickIE(org.openqa.selenium.WebDriver driver,
                                            String elementID)

sleep

public static void sleep(Long timeToSleep)
Make actual thread sleep for X mili-seconds

Parameters:
timeToSleep -

clickAndWaitForElementAttributeChange

public static void clickAndWaitForElementAttributeChange(org.openqa.selenium.WebElement elementToClick,
                                                         String attributeType,
                                                         String attributeValue)
Click on a WebElement as many times are necessary checking if some attribute value has changed

Parameters:
elementToClick -
attributeType -
attributeValue -

clickAndWaitForElementToDesappear

public static void clickAndWaitForElementToDesappear(org.openqa.selenium.WebElement elementToClick)
Click on some WebElement as many times are necessary checking if it desappeared

Parameters:
elementToClick -

selectRadioButton

public static void selectRadioButton(org.openqa.selenium.WebElement radioToClick)
Select radio button

Parameters:
radioToClick -


Copyright © 2010-2011. All Rights Reserved.