List of usage examples for org.openqa.selenium WebElement isDisplayed
boolean isDisplayed();
From source file:facetsTest.java
@Test public void findSearchBar() { driver.setJavascriptEnabled(true);/*from w ww . j a v a 2 s . co m*/ try { driver.get(page_url); Thread.sleep(14); WebElement searchBar = driver.findElement(By.xpath("//div[@id=\"search-and-facet\"]/form/input")); assertTrue(searchBar.isDisplayed()); System.out.println("Search bar found"); } catch (Exception e) { System.out.println("Search Bar is not present.Error : " + e); } }
From source file:app.fynd.Pages.MajorFlowSanityPage.java
License:Open Source License
public void scroll(WebElement element) throws InterruptedException { boolean isDisplayed = false; do {//ww w. j a v a 2 s.co m try { isDisplayed = element.isDisplayed(); System.out.println(isDisplayed); if (isDisplayed) { System.out.println("break statement executed"); break; } } catch (Exception NoSuchElementException) { // TODO: handle exception scroll(1); System.out.println("In catch block"); continue; } } while (isDisplayed); }
From source file:at.tugraz.ist.cucumber.SeleniumStepdefs.java
License:Open Source License
@When("^I use the top search box to search for a project called \"([^\"]*)\"$") public void I_use_the_top_search_box_to_search_for_a_project_called(String projectName) throws Throwable { WebElement largeTopSearchBox = driver().findElement(By.xpath("//*[@id='largeMenu']/div[4]/input")); WebElement mobileSearchBox = driver().findElement(By.xpath("//*[@id='smallSearchBar']/input")); WebElement mobileSearchButton = driver().findElement(By.id("mobileSearchButton")); if (largeTopSearchBox.isDisplayed()) { largeTopSearchBox.clear();//from w w w .j a v a2 s . c o m largeTopSearchBox.sendKeys(projectName); largeTopSearchBox.sendKeys(Keys.RETURN); jqueryWait(); } else if (mobileSearchButton.isDisplayed()) { mobileSearchButton.click(); mobileSearchBox.clear(); mobileSearchBox.sendKeys(projectName); mobileSearchBox.sendKeys(Keys.RETURN); jqueryWait(); } }
From source file:basicweb.ElementDisplayed.java
@Test public void testLetsKodeIt() throws InterruptedException { driver.get(baseUrl1);/* ww w. j a va 2 s . c o m*/ WebElement textBox = driver.findElement(By.id("displayed-text")); System.out.println("Text Box Displayed: " + textBox.isDisplayed()); Thread.sleep(3000); WebElement hideButton = driver.findElement(By.id("hide-textbox")); hideButton.click(); System.out.println("Clicked on hide button"); System.out.println("Text Box Displayed: " + textBox.isDisplayed()); Thread.sleep(3000); // Added code to scroll up because the element was hiding behind the top navigation menu // You will learn about scrolling in future lecture js.executeScript("window.scrollBy(0, -190);"); WebElement showButton = driver.findElement(By.id("show-textbox")); showButton.click(); System.out.println("Clicked on show button"); System.out.println("Text Box Displayed: " + textBox.isDisplayed()); }
From source file:basicweb.ElementDisplayed.java
@Test public void testExpedia() throws InterruptedException { driver.get(baseUrl2);/* ww w . jav a 2 s . c o m*/ WebElement childDropdown = driver.findElement(By.id("package-1-age-select-1")); System.out.println("Child Drpdown Displayed: " + childDropdown.isDisplayed()); }
From source file:bi.meteorite.pages.LoginPage.java
License:Apache License
public List<Map<Object, String>> getResultTable() { //FluentWait<WebDriver> myDynamicElement = (new WebDriverWait(this.getDriver(), 10)).withMessage("Waiting 10"); //this.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); try {//ww w. j a v a 2s . co m Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } //.until(ExpectedConditions.presenceOfElementLocated(By.className("table_wrapper"))); List<WebElement> ele = findByClass("table_wrapper"); for (WebElement el : ele) { if (el.isDisplayed()) { return SaikuTable.withColumns("Product Family", "Store Sales") .readRowsFrom(el.findElement(org.openqa.selenium.By.xpath(".//table"))); } } return null; }
From source file:bingbot.BingBot.java
/** * @param n number of searches to execute * @param file file to get user data from * @throws java.io.IOException/*from w w w . j a v a2 s.co m*/ * @throws java.lang.InterruptedException */ public void search(int m, int n, File file) throws Exception { System.out.println("Search method entered..."); scanner = new Scanner(file); Scanner sc = new Scanner(new File("./files/dict")); String next = scanner.next(); String name = null; String password = null; while (!next.equals("END")) { name = next; password = scanner.next(); next = scanner.next(); } for (int k = 0; k < m; k++) { driver.get("http://live.com"); try { WebElement signout = driver.findElement(By.id("c_signout")); if (!signout.isDisplayed()) { return; } } catch (Exception e) { System.out.println("NO SUCH ELEMENT 'C_SIGNOUT'"); System.out.println("SIGNING IN"); } WebElement username = driver.findElement(By.id("i0116")); username.sendKeys(name); WebElement userpassword = driver.findElement(By.id("i0118")); userpassword.sendKeys(password); WebElement signin = driver.findElement(By.id("idSIButton9")); signin.click(); Thread.sleep(10000); for (int j = 0; j < 41238; j++) { String word = sc.next(); list[j] = word; } for (int i = 0; i < n; i++) { Random rand = new Random(); driver.get("https://bing.com/"); WebElement query = driver.findElement(By.id("sb_form_q")); query.sendKeys(list[rand.nextInt(41238)]); WebElement go = driver.findElement(By.id("sb_form_go")); go.click(); Thread.sleep(rand.nextInt(5000) + 5000); } } seleniumServer.stop(); }
From source file:br.eti.kinoshita.selenium.util.Utils.java
License:Open Source License
/** * Wait for assync content in a determined period * /*from ww w .j a v a 2 s .c o 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.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebBase.java
License:Open Source License
public void isVisibleDisabled() { List<WebElement> elementsFound = getElements(); if (elementsFound.size() > 0) { WebElement e = elementsFound.get(0); // Tem que estar Visvel e Desabilitado, se estiver invisvel OU // habilitado lana a exception if (e.getTagName().toLowerCase().equals("input") || e.getTagName().toLowerCase().equals("select") || e.getTagName().toLowerCase().equals("a")) { // Verifica tambm se tem o atributo READONLY no elemento String readonlyAttribute = e.getAttribute("readonly"); String disabledAttribute = e.getAttribute("disabled"); // SE no estiver visivel OU (no possuir o attr DISABLED E no // possuir o attr READONLY) ENTO de erro! if (!e.isDisplayed() || (disabledAttribute == null && readonlyAttribute == null)) { throw new BehaveException(message.getString("exception-element-not-displayed-or-enabled", getElementMap().name())); }/*from w w w. j a v a 2 s. c om*/ } else { // Faz a verificao se esta desabilitado por meio das classes // de css para os casos de combo estilo Primefaces e Richfaces String classes = e.getAttribute("class"); if (!e.isDisplayed() || !classes.contains("disabled")) { throw new BehaveException(message.getString("exception-element-not-displayed-or-enabled", getElementMap().name())); } } } else { throw new BehaveException(message.getString("exception-element-not-found", getElementMap().name())); } }
From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebBaseTest.java
License:Open Source License
@Test @Ignore//from w w w .ja v a2 s. c o m public void testVerifyState() { WebElement element = Mockito.mock(WebElement.class); Mockito.when(element.isDisplayed()).thenReturn(true); WebDriver driver = Mockito.mock(WebDriver.class); Mockito.when(driver.findElement((By) Mockito.anyObject())).thenReturn(element); Runner runner = Mockito.mock(Runner.class); Mockito.when(runner.getDriver()).thenReturn(driver); WebBase webBase = new WebBase(); ElementMap mapa = Mockito.mock(ElementMap.class); Mockito.when(mapa.locator()).thenReturn(new String[] { "ID" }); Mockito.when(mapa.locatorType()).thenReturn(ElementLocatorType.XPath); webBase.setRunner(runner); webBase.setElementMap(mapa); }