List of usage examples for org.openqa.selenium By tagName
public static By tagName(String tagName)
From source file:co.edu.uniandes.csw.RigitalApp.test.SQLDevTest.java
@Test public void testDesactivarMaquina() throws Exception { Thread.sleep(2000);//from www . j a v a 2 s. c om List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(3).getText().equals("true")) { elems.get(0).findElement(By.tagName("input")).click(); } } Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click(); driver.get(baseUrl + "/RigitalApp.web/sQLDev.html"); Thread.sleep(2000); List<WebElement> table2 = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean def = true; for (WebElement webElement : table2) { List<WebElement> elems = webElement.findElements(By.xpath("td")); String val = elems.get(3).getText(); boolean temp = !val.equals("true"); System.out.println(temp); def = def && temp; } Thread.sleep(4000); assertTrue(def); }
From source file:co.edu.uniandes.csw.RigitalApp.test.UnidadDeRedTest.java
@Test public void testDesactivarMaquina() throws Exception { Thread.sleep(2000);/*w w w . j a v a2 s . c o m*/ List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(3).getText().equals("true")) { elems.get(0).findElement(By.tagName("input")).click(); } } Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click(); driver.get(baseUrl + "/RigitalApp.web/unidadDeRed.html"); Thread.sleep(2000); List<WebElement> table2 = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean def = true; for (WebElement webElement : table2) { List<WebElement> elems = webElement.findElements(By.xpath("td")); String val = elems.get(3).getText(); boolean temp = !val.equals("true"); System.out.println(temp); def = def && temp; } Thread.sleep(4000); assertTrue(def); }
From source file:co.edu.uniandes.csw.RigitalApp.test.WikiTest.java
@Test public void testDesactivarWiki() throws Exception { Thread.sleep(2000);// w ww .ja va2 s . c om List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(3).getText().equals("true")) { elems.get(0).findElement(By.tagName("input")).click(); } } Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click(); Thread.sleep(2000); List<WebElement> table2 = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean def = true; for (WebElement webElement : table2) { List<WebElement> elems = webElement.findElements(By.xpath("td")); String val = elems.get(3).getText(); boolean temp = !val.equals("true"); System.out.println(temp); def = def && temp; } Thread.sleep(4000); assertTrue(def); }
From source file:com.amazon.alexa.avs.AVSApp.java
License:Open Source License
/** * Performs amazon LWA login using the given <tt>driver</tt>. * //from w w w.j a v a2 s . c o m * @param driver Driver which is already configured to LWA login page. */ private void authenticate(final WebDriver driver) { log.debug("Title : {}", driver.getTitle()); new WebDriverWait(driver, 1000) .until(ExpectedConditions.and(ExpectedConditions.presenceOfElementLocated(By.id("ap_email")), ExpectedConditions.presenceOfElementLocated(By.id("ap_password")))); log.info("Auto logging in to LWA"); final WebElement username = driver.findElement(By.id("ap_email")); final WebElement password = driver.findElement(By.id("ap_password")); username.sendKeys(deviceConfig.getLWAUsername()); password.sendKeys(deviceConfig.getLWAPassword()); final WebElement button = driver.findElement(By.tagName("button")); button.click(); }
From source file:com.androidwhy.modules.test.selenium.Selenium2.java
License:Apache License
/** * ???./*www.ja v a 2 s . c o m*/ */ public boolean isTextPresent(String text) { String bodyText = driver.findElement(By.tagName("body")).getText(); return bodyText.contains(text); }
From source file:com.arifnazarpurwandaru.selenium.MainFrame.java
private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed try {//from ww w . ja v a2 s .com // MarionetteDriverManager.getInstance().setup(); System.out.println("Mulai Pencarian..."); // Runtime.getRuntime().exec("TASKKILL /F /IM Firefox.exe"); // Runtime.getRuntime().exec("TASKKILL /F /IM iexplore.exe"); // Runtime.getRuntime().exec("TASKKILL /F /IM iexplore.exe"); WebDriver driver = null; String kereta = ((ComboItem) comboKereta.getSelectedItem()).getValue(); //use proxy if (radioUseProxy.isSelected()) { String proxyHost = hostProxy.getText() + ":" + portProxy.getText(); Proxy proxy = new Proxy(); proxy.setHttpProxy(proxyHost); proxy.setSslProxy(proxyHost); proxy.setFtpProxy(proxyHost); proxy.setSocksUsername(usernameProxy.getText()); proxy.setSocksPassword(new String(passwordProxy.getPassword())); DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(CapabilityType.PROXY, proxy); driver = new ChromeDriver(cap); } else { // driver = new MarionetteDriver(); driver = new ChromeDriver(); } // hmin = Integer.valueOf(args[0]).intValue(); ComboItem link = (ComboItem) comboLink.getSelectedItem(); driver.get(link.getValue()); List<WebElement> list = null; int counter = 1; boolean keeploop = true; while (/**list==null || list.size() == 0**/ keeploop) { try { Select selectTgl = new Select(driver.findElement(By.name("tanggal"))); selectTgl.selectByIndex(comboTanggal.getSelectedIndex()); ComboItem stFrom = (ComboItem) comboStBerangkat.getSelectedItem(); Select selectFrom = new Select(driver.findElement(By.name("origination"))); selectFrom.selectByValue(stFrom.getValue()); ComboItem stTo = (ComboItem) comboStTujuan.getSelectedItem(); Select selectTo = new Select(driver.findElement(By.name("destination"))); selectTo.selectByValue(stTo.getValue()); Select selectAdult = new Select(driver.findElement(By.name("adult"))); selectAdult.selectByValue("1"); WebElement element = driver.findElement(By.name("Submit")); element.click(); // Thread.sleep(1000); //tunggu sampe page ready, nandainnya kalo element div dengan css class "itReservationContent" muncul WebElement elementForWait = (new WebDriverWait(driver, 1)).until( ExpectedConditions.visibilityOfElementLocated(By.className("itReservationContent"))); //end wait list = driver.findElements(By.className("itButton")); if (list != null && list.size() > 0) { List<WebElement> listForm = driver.findElements(By.tagName("form")); for (WebElement form : listForm) { List<WebElement> listInput = form.findElements(By.tagName("input")); for (WebElement input : listInput) { if (input.getAttribute("value").equalsIgnoreCase(kereta)) { WebElement btn = form.findElement(By.className("itButton")); btn.click(); System.out.println("========================>KLIK BOOKING"); keeploop = false; throw new KlikException("BerhasilKlik"); } } } } System.out.println("==========================> looping ke: " + counter); counter++; } catch (KlikException ke) { System.out.println("================> Masuk Klik Exception"); keeploop = false; break; } catch (Exception e) { e.printStackTrace(); System.out.println("===================> Reconecting..." + link.getValue()); driver.get(link.getValue()); } } // System.out.println("ada keretaaaaaa: "+list.size()); List<WebElement> listInput = driver.findElements(By.tagName("input")); for (WebElement input : listInput) { if (input.getAttribute("type").equals("checkbox")) { input.click(); break; } } WebElement lanjut = driver.findElement(By.cssSelector("input[type='submit'][name='booking']")); lanjut.click(); //Ngisi Tikete //Nunggu disit //tunggu sampe page ready, nandainnya kalo element div dengan css class "txt_first_name_adult_1" muncul WebElement elementForWait = (new WebDriverWait(driver, 3)) .until(ExpectedConditions.visibilityOfElementLocated(By.id("txt_first_name_adult_1"))); //end wait WebElement namaPenumpang = driver.findElement(By.id("txt_first_name_adult_1")); WebElement ktp = driver.findElement(By.id("txt_passport_1")); WebElement contactName = driver.findElement(By.id("txt_contact_first_name")); WebElement contactEmail = driver.findElement(By.id("txt_contact_email")); WebElement contactPhone = driver.findElement(By.id("txt_contact_phone")); WebElement contactAddress = driver.findElement(By.id("txt_contact_home_address")); namaPenumpang.sendKeys(txtNamaPenumpang.getText()); ktp.sendKeys(txtNoKTP.getText()); contactName.sendKeys(txtNamaPenumpang.getText()); contactEmail.sendKeys(txtEmail.getText()); contactPhone.sendKeys(txtNoTelp.getText()); contactAddress.sendKeys(txtAlamat.getText()); playSound(); JOptionPane.showMessageDialog(rootPane, "Booking sudah tersedia, Silakan inputkan Captcha!! Dan lanjutkan secara manual", "Informasi", JOptionPane.INFORMATION_MESSAGE); this.setAlwaysOnTop(true); System.out.println("DONE"); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.atanas.kanchev.testframework.selenium.handlers.Finder.java
License:Apache License
/** * {@inheritDoc}// ww w. j a v a 2 s.com */ @Override public Finder byLabelForId(String id) { boolean labelFound = false; ((SeleniumContext) context().getCurrentContext()) .setWebElementsList(findElements(By.tagName(CommonPageDefinitions.HTML.LABEL.getDefinition()))); if (!((SeleniumContext) context().getCurrentContext()).getWebElementsList().isEmpty()) { for (WebElement labelElement : ((SeleniumContext<WebDriver>) context().getCurrentContext()) .getWebElementsList()) { String s = labelElement.getAttribute(CommonPageDefinitions.HTML.ATTRIBUTE_FOR.getDefinition()); if (s.equals(id)) { ((SeleniumContext) context().getCurrentContext()).setCurrentElement(labelElement); labelFound = true; break; } } if (!labelFound) throw new RuntimeException("Label not found"); } return this; }
From source file:com.atanas.kanchev.testframework.selenium.handlers.Finder.java
License:Apache License
/** * {@inheritDoc}//from w ww .j av a 2s. com */ @Override public Finder byHref(String href) { boolean navigated = false; ((SeleniumContext) context().getCurrentContext()) .setWebElementsList(findElements(By.tagName(CommonPageDefinitions.HTML.ANCHOR.getDefinition()))); if (!((SeleniumContext) context().getCurrentContext()).getWebElementsList().isEmpty()) { for (WebElement anchor : ((SeleniumContext<WebDriver>) context().getCurrentContext()) .getWebElementsList()) { if (anchor.getAttribute("href").equals(href)) { ((SeleniumContext) context().getCurrentContext()).setCurrentElement(anchor); navigated = true; break; } } if (!navigated) throw new RuntimeException("Label not found"); } return this; }
From source file:com.atanas.kanchev.testframework.selenium.handlers.Probe.java
License:Apache License
/** * {@inheritDoc}/* www .j ava 2 s.co m*/ */ @Override public boolean hasLinkToURL(String url) { boolean hasAnchorAndHref = false; ((SeleniumContext) context().getCurrentContext()) .setWebElementsList(((SeleniumContext<WebDriver>) context().getCurrentContext()).getDriver() .findElements(By.tagName(CommonPageDefinitions.HTML.ANCHOR.getDefinition()))); for (WebElement anchor : ((SeleniumContext<WebDriver>) context().getCurrentContext()) .getWebElementsList()) { if (anchor.getAttribute("href") != null && anchor.getAttribute("href").contains(url)) ; hasAnchorAndHref = true; break; } return hasAnchorAndHref; }
From source file:com.atlassian.webdriver.greenhopper.page.admin.GreenHopperLicenseDetailsPage.java
@Init private void readLicense() { if (Check.elementExists(By.className("errMsg"), updateLicenseForm)) { errorMessage = updateLicenseForm.findElement(By.className("errMsg")).getText(); }/* www. j a v a 2 s. com*/ List<WebElement> rows = licenseTable.findElements(By.tagName("tr")); organisation = rows.get(0).findElement(ByJquery.$("td ~ td")).getText(); if (StringUtils.isNotEmpty(organisation)) { licenseIsLoaded = true; purchaseDate = formatDate(rows.get(1).findElement(ByJquery.$("td ~ td strong")).getText()); WebElement licenseTypeColumn = rows.get(2).findElement(ByJquery.$("td ~ td")); licenseType = licenseTypeColumn.findElement(By.tagName("strong")).getText(); expiryDate = formatDate(extractExpiryDate(licenseTypeColumn.getText())); serverId = rows.get(3).findElement(ByJquery.$("td ~ td strong")).getText(); supportEntitlmentNumber = rows.get(4).findElement(ByJquery.$("td ~ td strong")).getText(); } }