List of usage examples for org.openqa.selenium By tagName
public static By tagName(String tagName)
From source file:com.cognifide.qa.bb.test.expectedconditions.CommonExpectedConditionsTest.java
License:Apache License
@Test public void shouldAnswerTrueWhenScopedElementDoesNotContainElement() { //given/*from w ww . j av a 2 s . co m*/ WebElement element = webDriver.findElement(By.className(EMTPY_CONTAINER_CSS_CLASS)); By by = By.tagName(PRESENT_TAG); //when boolean actual = waitFor(CommonExpectedConditions.scopedElementLocatedByNotPresent(element, by)); //then assertThat(actual).as("check if element does not contain element").isTrue(); }
From source file:com.cognifide.qa.bb.test.expectedconditions.CommonExpectedConditionsTest.java
License:Apache License
@Test public void shouldThrowExceptionWhenScopedElementContainsElement() { //given// w w w . jav a2 s. c o m exception.expect(TimeoutException.class); WebElement element = webDriver.findElement(By.className(CONTAINER_CSS_CLASS)); By by = By.tagName(PRESENT_TAG); //when waitFor(CommonExpectedConditions.scopedElementLocatedByNotPresent(element, by)); }
From source file:com.cognifide.qa.bb.test.expectedconditions.CommonExpectedConditionsTest.java
License:Apache License
@Test public void shouldAnswerTrueWhenElementHeightIsGratherThanTen() { //given/* ww w . java2s.co m*/ WebElement element = webDriver.findElement(By.tagName(PRESENT_TAG)); //when boolean actual = waitFor( CommonExpectedConditions.heightOfElementGreaterThan(element, SMALL_ELEMENT_HEIGHT)); //then assertThat(actual).as("check if element has height greater than %d", SMALL_ELEMENT_HEIGHT).isTrue(); }
From source file:com.cognifide.qa.bb.test.expectedconditions.CommonExpectedConditionsTest.java
License:Apache License
@Test public void shouldThrowExceptionWhenElementHeightIsSmallerThanHundred() { //given//from w ww. ja v a 2 s. c o m exception.expect(TimeoutException.class); WebElement element = webDriver.findElement(By.tagName(PRESENT_TAG)); //when waitFor(CommonExpectedConditions.heightOfElementGreaterThan(element, BIG_ELEMENT_HEIGHT)); }
From source file:com.cognifide.qa.bb.test.expectedconditions.CommonExpectedConditionsTest.java
License:Apache License
@Test public void shouldAnswerTrueWhenElementsSizeIsConstant() { //given/*from w w w . j ava 2s . co m*/ WebElement element = webDriver.findElement(By.tagName(HIGHEST_CONTAINER)); By by = By.tagName(CONTAINER_TAG); //when boolean actual = waitFor(CommonExpectedConditions.listSizeIsConstant(element, by)); //then assertThat(actual).as("check if element contains constant number of %s", CONTAINER_TAG).isTrue(); }
From source file:com.cognifide.qa.bb.test.expectedconditions.CommonExpectedConditionsTest.java
License:Apache License
private WebElement findPresentTagElement() { return webDriver.findElement(By.tagName(PRESENT_TAG)); }
From source file:com.coinbot.captcha.CaptchaDetector.java
License:Open Source License
private BufferedImage captureCaptcha(WebDriver driver, WebElement captcha) { WebElement iframe = null;//from w w w. j av a 2 s .com try { iframe = captcha.findElement(By.tagName("iframe")); } catch (NoSuchElementException e) { } // Si tiene iframe es la version 2 if (iframe != null) { driver.switchTo().frame(iframe); JavascriptExecutor js2 = (JavascriptExecutor) driver; js2.executeScript("document.getElementById('loading').style.display = 'none'"); js2.executeScript("document.getElementById('overlay').style.display = 'inline'"); driver.switchTo().defaultContent(); } byte[] screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); BufferedImage imageScreen = null; try { imageScreen = ImageIO.read(new ByteArrayInputStream(screen)); } catch (IOException ex) { ex.printStackTrace(); } Point capLocation = captcha.getLocation(); Dimension capDimension = captcha.getSize(); return imageScreen.getSubimage(capLocation.x, capLocation.y, capDimension.width, capDimension.height); }
From source file:com.coinbot.core.InputAddressDetector.java
License:Open Source License
public void insertAddress(String address) { List<WebElement> inputs = driver.findElements(By.tagName("input")); for (WebElement input : inputs) { if (input.getAttribute("name").length() > 20) { input.sendKeys(address);// w w w. j a v a2s . co m } } }
From source file:com.coinbot.core.Worker.java
License:Open Source License
@Override public void run() { File pathToBinary = new File("/home/jian/Descargas/firefox46/bin/firefox"); // Firefox 46 needed FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary); FirefoxProfile profile = new FirefoxProfile(); FirefoxDriver driver = new FirefoxDriver(ffBinary, profile); CoinbotApplication.ui.workerQueue.addWorker(workerPanel); while (CoinbotApplication.bot.isRunning()) { // Sacamos un "claim" de la cola Claim claim = CoinbotApplication.bot.getClaimQueue().next(); if (claim == null) { continue; }/*from www . ja va 2 s . c om*/ claim.getPanel().reset(); claim.getPanel().getProgressBar().setMaximum(10); workerPanel.addClaim(claim.getPanel()); claim.getPanel().nextStep("Opening URL"); try { driver.manage().timeouts().pageLoadTimeout(12, TimeUnit.SECONDS); driver.navigate().to(new URL(claim.getFaucet().getUrl())); } catch (MalformedURLException e) { e.printStackTrace(); continue; } catch (TimeoutException e) { // Busca un elemento, si no lo encuentra que vuelva a cargar e.printStackTrace(); } // Detectando captcha claim.getPanel().nextStep("Detecting Captcha"); CaptchaDetector captchaDetector = new CaptchaDetector(); CaptchaService captcha = null; try { captcha = captchaDetector.find(driver, driver.findElement(By.tagName("body"))); } catch (NoSuchElementException ex) { ex.printStackTrace(); claim.getPanel().nextStep("Body not found!"); continue; } catch (UnrecognizedCaptcha ex) { ex.printStackTrace(); claim.getPanel().nextStep("Captcha not recognized."); continue; } catch (Exception ex) { continue; } claim.getPanel().nextStep("Trying auto resolving"); // Intentamos buscar el hash en la DB CaptchaHash ch = new CaptchaHash(captcha); String answer = CoinbotApplication.captchaDatabase.getAnswer(ch.getHash()); // Si no enctramos la respuesta en la bd se la pedimos al usuario if (answer == null) { claim.getPanel().nextStep("Waiting for captcha answer ..."); // Encolar captcha CoinbotApplication.bot.getCaptchaQueue().toQueue(captcha); // Esperar la resolucion del captcha CaptchaTimer timer = new CaptchaTimer(captcha, 35); timer.start(); // Esperamos a la resolucion while (!timer.isExpired() && !captcha.resolved()) { CoinbotApplication.ui.captchaQueue.getCaptchaPanel(captcha).setTimer(timer.getSecondsLeft()); } if (!captcha.resolved()) { CoinbotApplication.captchaDatabase.addCaptcha(ch); continue; } } // Guardamos el captcha en la DB CoinbotApplication.captchaDatabase.addCaptcha(new CaptchaHash(captcha)); // Y la imagen en un archivo try { ImageIO.write(captcha.getImage(), "png", new File("coinbot/captchas/" + ch.getHash() + ".png")); } catch (IOException e) { e.printStackTrace(); } // Envia la respuesta al input captcha.answerToInput(driver); // Desencolar captcha CoinbotApplication.bot.getCaptchaQueue().deQueue(captcha); // Escribir address claim.getPanel().nextStep("Detecting input address"); InputAddressDetector iad = new InputAddressDetector(driver); iad.insertAddress(claim.getBtcAddress()); //claim.getPanel().nextStep("Detecting Antibot"); // Detectar antibot (puzzle no soportado) // Resolver antibot // submit claim.getPanel().nextStep("Submiting ..."); WebElement submit = driver.findElement(By.id("address")); submit.submit(); claim.getPanel().nextStep("Checking response"); //claim.getPanel().nextStep("Successfull claim!"); /*WebElement out = null; try { out = driver.findElement(By.className("alert-success")); } catch (NoSuchElementException e) { } try { out = driver.findElement(By.className("alert-danger")); } catch (NoSuchElementException e) { } */ //claim.getPanel().nextStep("Failed claim!"); claim.getPanel().done(); workerPanel.removeClaim(claim.getPanel()); claim.getTimer().done(2000, 1); CoinbotApplication.bot.getClaimQueue().toQueue(claim); try { Thread.sleep(25000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { driver.close(); } catch (Exception e) { } CoinbotApplication.ui.workerQueue.removeWorker(workerPanel); System.out.println("Worker " + workerId + " end work!"); }
From source file:com.comcast.dawg.house.AdvanceFilterNavigator.java
License:Apache License
/** * Checks the condition list for the given values. * @param checked All the conditions that are checked * @param unchecked All the conditions that are in the list but not checked */// ww w.j av a2 s.c o m public void verifyConditions(String[] checked, String[] unchecked) { WebElement conditionList = driver.findElementByClassName(IndexPage.CONDITION_LIST); List<WebElement> conditions = conditionList.findElements(By.tagName("div")); Assert.assertEquals(conditions.size(), checked.length + unchecked.length); verifyConditions(conditions, checked, true); verifyConditions(conditions, unchecked, false); }