List of usage examples for org.openqa.selenium By className
public static By className(String className)
From source file:co.flexmod.selenium.example.integration.HelloWorldPage.java
License:Apache License
public String panelHeader() { WebElement pnlHeader = webDriver.findElement(By.id(PNL_HELLO_WORLD)); return pnlHeader.findElement(By.className("ui-panel-title")).getText(); }
From source file:com.arifnazarpurwandaru.selenium.MainFrame.java
private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed try {//from w w w . j a v a 2 s .c o m // 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.arifnazarpurwandaru.selenium.MainFrame.java
private void btnSearchBiasaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchBiasaActionPerformed try {// w ww. j a va 2 s .c om Runtime.getRuntime().exec("TASKKILL /F /IM Firefox.exe"); Runtime.getRuntime().exec("TASKKILL /F /IM iexplore.exe"); WebDriver driver = null; //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 ChromeDriver(); } ComboItem link = (ComboItem) comboLink.getSelectedItem(); driver.get(link.getValue()); List<WebElement> list = null; int counter = 1; while (list == null || list.size() == 0) { try { Select selectTgl = new Select(driver.findElement(By.name("tanggal"))); selectTgl.selectByIndex(comboTanggalBiasa.getSelectedIndex()); ComboItem ck = (ComboItem) comboStBerangkatBiasa.getSelectedItem(); Select selectFrom = new Select(driver.findElement(By.name("origination"))); selectFrom.selectByValue(ck.getValue()); ComboItem ct = (ComboItem) comboStTujuanBiasa.getSelectedItem(); Select selectTo = new Select(driver.findElement(By.name("destination"))); selectTo.selectByValue(ct.getValue()); Select selectAdult = new Select(driver.findElement(By.name("adult"))); selectAdult.selectByValue("1"); WebElement element = driver.findElement(By.name("Submit")); element.click(); //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")); System.out.println("==========================> looping ke: " + counter); counter++; } catch (Exception e) { System.out.println("===================> Reconecting..." + link.getValue()); driver.get(link.getValue()); } } System.out.println("ada keretaaaaaa: " + list.size()); System.out.println("DONE"); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.atlassian.jira.pageobjects.components.LicenseBanner.java
License:Open Source License
private PageElement getCloseIcon() { return banner.find(By.className("icon-close")); }
From source file:com.atlassian.jira.webtest.webdriver.tests.visualregression.TestAuditLogVisualRegression.java
@Test public void testAuditingView() throws InterruptedException { testkit.auditing().clearAllRecords(); generateRecords(300);/*from w w w .j ava2 s .c om*/ goTo("/auditing/view"); clickOnElement(".show-details"); sleep(1000); addElementsToIgnore(By.className("auditing-date")); assertUIMatches("auditing-view"); }
From source file:com.atlassian.jira.webtest.webdriver.tests.visualregression.TestAuditLogVisualRegression.java
@Test public void testAuditingViewSearchPending() throws InterruptedException { visualComparer.setWaitforJQueryTimeout(0); testkit.auditing().clearAllRecords(); generateRecords(3);/* www . j a va2 s . c o m*/ goTo("/auditing/view"); jira.backdoor().barrier().raiseBarrierAndRun("auditingGetRecords", new Runnable() { @Override public void run() { elementFinder.find(By.id("searcher-query")).type("test"); clickOnElement(".search-button"); //we do additional click to ensure focus stays out of search input clickOnElement(".show-details"); sleep(1000); addElementsToIgnore(By.className("auditing-date")); assertUIMatches("auditing-search-pending"); } }); }
From source file:com.atlassian.jira.webtest.webdriver.tests.visualregression.TestIntegratedPluginsVisualRegression.java
@Test public void testManagePlugins() { visualComparer.setWaitforJQueryTimeout(1000); visualComparer.setRefreshAfterResize(false); goTo("/plugins/servlet/upm/manage/action-required"); Poller.waitUntilFalse(finder.find(By.className(".loading.filter-box")) .withTimeout(TimeoutType.SLOW_PAGE_LOAD).timed().isPresent()); assertUIMatches("upm-manage"); }
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(); }//from www .j a v a 2s . c o m 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(); } }
From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java
License:Apache License
public By getFinderType(String identifier, String idValue) throws Exception { By findBy = null;/*from w w w . j a v a 2s . c o m*/ MobileWebIdentifyBy idType = null; try { idType = MobileWebIdentifyBy.valueOf(identifier.toUpperCase()); } catch (Throwable e) { throwUnsupportedIndentifierException(this.getName(), "getFinderType", identifier); } switch (identifier.toUpperCase()) { case "ID": findBy = By.id(idValue); break; case "NAME": findBy = By.name(idValue); break; case "CLASS": findBy = By.className(idValue); break; case "LINK_TEXT": findBy = By.linkText(idValue); break; case "PARTIAL_LINK_TEXT": findBy = By.partialLinkText(idValue); break; case "XPATH": findBy = By.xpath(idValue); break; case "CSS": findBy = By.cssSelector(idValue); break; case "TAG": findBy = By.tagName(idValue); break; } return findBy; }
From source file:com.autocognite.selenium.lib.SeleniumWebUiDriver.java
License:Apache License
@SuppressWarnings("incomplete-switch") public By getFinderType(String identifier, String idValue) throws Exception { By findBy = null;/*from ww w . ja v a 2s. com*/ WebIdentifyBy idType = null; try { idType = WebIdentifyBy.valueOf(identifier.toUpperCase()); } catch (Throwable e) { throwUnsupportedIndentifierException(Configurator.getComponentName("WEBDRIVER_AUTOMATOR"), "getFinderType", identifier); } switch (idType) { case ID: findBy = By.id(idValue); break; case NAME: findBy = By.name(idValue); break; case CLASS: findBy = By.className(idValue); break; case LINK_TEXT: findBy = By.linkText(idValue); break; case PARTIAL_LINK_TEXT: findBy = By.partialLinkText(idValue); break; case XPATH: findBy = By.xpath(idValue); break; case CSS: findBy = By.cssSelector(idValue); break; case TAG: findBy = By.tagName(idValue); break; } return findBy; }