List of usage examples for org.openqa.selenium WebElement isEnabled
boolean isEnabled();
From source file:facets_testing.java
@Test public void testCreatorMoreButtonWorking() { driver.setJavascriptEnabled(true);/*from w w w . ja va 2 s. c o m*/ try { driver.get(page_url); Thread.sleep(14); driver.findElement(By.xpath("//div[@id=\"drs_creator_sim\"]/div/div[2]/button")).click(); WebElement more_creators_model = driver.findElement(By.xpath("//div[@id=\"drs_modal_creator_sim\"]")); assertTrue(more_creators_model.isEnabled()); } catch (Exception e) { System.out.println("More Creators button is not working.Error : " + e); } }
From source file:facets_testing.java
@Test public void testCreationYearMoreButtonWorking() { driver.setJavascriptEnabled(true);//from w w w . j a va 2s .com try { driver.get(page_url); Thread.sleep(14); driver.findElement(By.xpath("//div[@id=\"drs_creation_year_sim\"]/div/div[2]/button")).click(); WebElement more_creation_years_model = driver .findElement(By.xpath("//div[@id=\"drs_modal_creation_year_sim\"]")); assertTrue(more_creation_years_model.isEnabled()); } catch (Exception e) { System.out.println("More Creation Years button is not working.Error : " + e); } }
From source file:facets_testing.java
@Test public void testSubjectMoreButtonWorking() { driver.setJavascriptEnabled(true);// ww w.j a v a 2 s. c om try { driver.get(page_url); Thread.sleep(14); driver.findElement(By.xpath("//div[@id=\"drs_subject_sim\"]/div/div[2]/button")).click(); WebElement more_subject_model = driver.findElement(By.xpath("//div[@id=\"drs_modal_subject_sim\"]")); assertTrue(more_subject_model.isEnabled()); } catch (Exception e) { System.out.println("More Subjects button is not working.Error : " + e); } }
From source file:br.eti.kinoshita.selenium.util.Utils.java
License:Open Source License
/** * Wait for assync content in a determined period * //from www. j a v a 2 s. co m * @param driver Selenium web driver. * @param by Selenium By expression. * @param timeout Selenium time out. * @return a WebElement asynchronously loaded. * @throws NoSuchElementException */ public static WebElement waitForAssyncContent(WebDriver driver, By by, Long timeout) throws NoSuchElementException { long end = System.currentTimeMillis() + (timeout); WebElement renderedWebElement = null; while (System.currentTimeMillis() < end) { try { renderedWebElement = driver.findElement(by); } catch (NoSuchElementException nsee) { LOGGER.debug(nsee.getMessage(), nsee); } if (renderedWebElement != null && renderedWebElement.isEnabled() && renderedWebElement.isDisplayed()) { return renderedWebElement; } try { Thread.sleep(1000); } catch (InterruptedException ie) { LOGGER.debug(ie.getMessage(), ie); } } if (renderedWebElement == null) { throw new NoSuchElementException("Could not locate assync content"); } try { if (renderedWebElement.isDisplayed()) { throw new NoSuchElementException("Element is not being displayed"); } } catch (Throwable t) { LOGGER.debug(t.getMessage(), t); } return renderedWebElement; }
From source file:br.ufmg.dcc.saotome.beholder.selenium.WebElementAdapter.java
License:Apache License
@Override public boolean isEnabled() { return new StaleExceptionResolver<Boolean>() { @Override//from ww w .j a v a 2s . co m public Boolean execute(WebElement element) { return element.isEnabled(); } }.waitForElement(); }
From source file:bst.cpo.automation.dm.actions.SystemOverview_Actions.java
public boolean Is_Enabled_Search_Button() { //<input type="submit" class="pure-button pure-button-primary" value="Search" ng-disabled="searchForm.$invalid"> try {/*from w w w . jav a 2 s . c o m*/ WebElement element = DMDriver .findElement(By.xpath("//*[@id='app']/div/div[4]/div/div/div[2]/div[1]/div[1]/form/input[2]")); if (element.isEnabled()) { return true; } return false; } catch (Exception e) { logThis("Exception during test occurred : " + e.getMessage()); } return false; }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public boolean isSelectOptionEnable(String selectLocator, String optionLocator) { Select select = new Select(findElement(selectLocator)); List<WebElement> options = select.getOptions(); log.debug("options found " + options.size() + " elements"); String[] locator = optionLocator.split("="); log.debug("Locator has " + locator.length + " elements"); String find;/* w ww . ja v a2 s .co m*/ if (locator.length > 1) { find = locator[1]; } else { find = locator[0]; } log.debug(" find is " + find); if (locator[0].contains(VALUE)) { log.debug("checking value"); for (WebElement we : options) { log.debug("Printing found options: " + we.getAttribute(VALUE)); if (we.getAttribute(VALUE).equals(find)) { return we.isEnabled(); } } } else if (locator[0].contains("id")) { log.debug("checking id"); for (WebElement we : options) { log.debug("Printing found options: " + we.getAttribute("id")); if (we.getAttribute("id").equals(find)) { return we.isEnabled(); } } } else if (locator[0].contains("index")) { log.debug("checking index"); for (WebElement we : options) { log.debug("Printing found options: " + we.getAttribute("index")); if (we.getAttribute("index").equals(find)) { return we.isEnabled(); } } } else { log.debug("checking text or label, default option"); for (WebElement we : options) { log.debug("Printing found options: " + we.getText()); if (we.getText().equals(find)) { return we.isEnabled(); } } } return false; }
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Selects an option from dropdown./*from www . jav a 2 s . c o m*/ * * @param dropDown * the drop down * @param optionsListXpath * the options list xpath * @param option * the option */ public static void selectFromDropdown(WebElement dropDown, String optionsListXpath, String option) { waitForElement(dropDown); if (dropDown.isDisplayed() && dropDown.isEnabled()) { click(dropDown); String initialValue = driver.switchTo().activeElement().getText(); boolean found = false; while (found == false) { driver.switchTo().activeElement().sendKeys(Keys.ARROW_DOWN); if (driver.switchTo().activeElement().getText().equals(initialValue)) { break; } else { if (driver.switchTo().activeElement().getText().equals(option)) { LogHandler.printToConsole( "\tSelecting the option : " + driver.switchTo().activeElement().getText()); driver.switchTo().activeElement().click(); found = true; } } } } }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Gets the element by text./*w w w .j av a 2 s . c o m*/ * * @param driver the driver * @param locator the locator * @param innerText the inner text * @param timeout the timeout * @return the element by text */ public static WebElement getElementByText(final WebDriver driver, final By locator, final String innerText, final Timeout timeout) { for (final WebElement webElement : getElements(driver, locator, timeout)) { if (webElement.isDisplayed() && webElement.isEnabled() && webElement.getText().trim().equalsIgnoreCase(innerText)) { return webElement; } } return null; }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Gets the element by text contains./*w ww .j ava 2s . co m*/ * * @param driver the driver * @param locator the locator * @param innerText the inner text * @param timeout the timeout * @return the element by text contains */ public static WebElement getElementByTextContains(final WebDriver driver, final By locator, final String innerText, final Timeout timeout) { for (final WebElement webElement : getElements(driver, locator, timeout)) { if (webElement.isDisplayed() && webElement.isEnabled() && webElement.getText().trim().contains(innerText)) { return webElement; } } return null; }