Exemplo n.º 1
0
 public void uncheck(String locator) {
   WebElement checkBox = driver.findElement(loc.autoLocator(locator));
   if (!checkBox.getAttribute("type").toLowerCase().equals("checkbox")) {
     throw new InvalidElementTypeException("This elementLocator is not a checkbox!");
   }
   if (checkBox.isSelected()) {
     checkBox.click();
   }
 }
Exemplo n.º 2
0
 public boolean isChecked(String locator) {
   WebElement checkBox = driver.findElement(loc.autoLocator(locator));
   if (!checkBox.getAttribute("type").toLowerCase().equals("checkbox")) {
     throw new InvalidElementTypeException("This elementLocator is not a checkbox!");
   }
   if (checkBox.getAttribute("checked").equals("checked")) {
     return true;
   } else {
     return false;
   }
 }
Exemplo n.º 3
0
 /**
  * Open site homepage and check that it has loaded correctly. This will set the currently selected
  * site to the value of page
  *
  * @param homepageURL URL of the homepage
  * @param homePageElement If homePageElement is not null kill tests if it does not exist
  */
 public void openHomepage(String homepageURL, WebElement homePageElement) throws Exception {
   driver.get(homepageURL);
   if (homePageElement != null) {
     if (!homePageElement.isDisplayed()) {
       throw new HomepageNotLoadedException();
     }
   }
 }
Exemplo n.º 4
0
 /**
  * Find out if an element is stale or not.
  *
  * @param element - An xpath locator
  * @return boolean - True if element location is found, otherwise false.
  * @throws Exception
  */
 public boolean isElementStale(WebElement element) {
   try {
     element.getLocation();
   } catch (StaleElementReferenceException Ex) {
     return true;
   }
   return false;
 }