Esempio 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();
   }
 }
Esempio 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;
   }
 }
Esempio 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();
     }
   }
 }
Esempio 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;
 }