List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:com.denimgroup.threadfix.selenium.pages.RemoteProvidersIndexPage.java
License:Mozilla Public License
public RemoteProvidersIndexPage saveMappingWhiteHat() { driver.findElementByClassName("modal-footer").findElement(By.linkText("Update Application")).click(); waitForInvisibleElement(driver.findElementByClassName("modal")); return new RemoteProvidersIndexPage(driver); }
From source file:com.dhenton9000.selenium.generic.BaseTest.java
protected boolean isNotOnPageViaLinkText(String linkText, WebDriver driver) { boolean isNotOnPage = false; try {//w w w . j a v a2s .co m driver.findElement(By.linkText(linkText)); } catch (NoSuchElementException err) { isNotOnPage = true; } return isNotOnPage; }
From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java
/** * generate the By selector/*ww w. ja va2 s. co m*/ * * @param selectorChoice the desired selector, eg by css Selector * @param selectorValue the string to search for * @return the By element */ public static By generateSelectorBy(SELECTOR_CHOICE selectorChoice, String selectorValue) { By selectorBy = null; switch (selectorChoice) { case id: selectorBy = By.id(selectorValue); break; case name: selectorBy = By.name(selectorValue); break; case className: selectorBy = By.className(selectorValue); break; case linkText: selectorBy = By.linkText(selectorValue); break; case xpath: selectorBy = By.xpath(selectorValue); break; case tagName: selectorBy = By.tagName(selectorValue); break; case cssSelector: selectorBy = By.cssSelector(selectorValue); break; case partialLinkText: selectorBy = By.partialLinkText(selectorValue); break; case wicketPathMatch: selectorBy = WicketBy.wicketPathMatch(selectorValue); break; case wicketPathContains: selectorBy = WicketBy.wicketPathContains(selectorValue); break; default: throw new AssertionError("unable to match selector " + selectorChoice.name()); } return selectorBy; }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java
protected void target_reloadbtn() { JavascriptExecutor jse = (JavascriptExecutor) getDriver(); jse.executeScript("window.scrollBy(0,-500)", ""); boolean breakIt; jse.executeScript("window.scrollBy(0,400)", ""); while (true) { breakIt = true;/*w w w . j a v a 2 s . co m*/ try { //*[@id="planDetails"]/div[2]/div[1]/div[4]/a WebElement reload = getDriver().findElement(By.linkText("Reload balance")); reload.click(); log.info("Success: Reload button is clicked"); waitForPageLoad(100); } catch (Exception e) { log.error("Fail : Failed to click on reload button"); breakIt = false; //System.out.println(e); //e.printStackTrace(); //e.printStackTrace(); //System.exit(0); } if (breakIt) { break; } } }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Util.java
protected void target_reloadbtn() { JavascriptExecutor jse = (JavascriptExecutor) getDriver(); jse.executeScript("window.scrollBy(0,-800)", ""); boolean breakIt; jse.executeScript("window.scrollBy(0,400)", ""); while (true) { breakIt = true;/* w ww . ja v a 2s.c o m*/ try { WebElement reload = getDriver().findElement(By.linkText("Reload balance")); reload.click(); log.info("Success: Reload button is clicked"); waitForPageLoad(100); } catch (Exception e) { log.error("Fail : Failed to click on reload button"); breakIt = false; } if (breakIt) { break; } } }
From source file:com.digi.selenium.util.common.PageNavigation.java
protected void clickCancel() throws InterruptedException { tryToClickElementByXPath("//*[@id='pay-getaway-foot']/div[2]/form/button[3]", 5).click(); Thread.sleep(500);/*from ww w. ja v a 2s . c o m*/ driver.switchTo().alert().accept(); waitForPageLoad(60); Thread.sleep(500); log.info("Success : Payment is cancelled "); List<WebElement> element = getDriver().findElements(By.linkText("Back")); //boolean isPresent=getDriver().findElements(By.linkText("Back")).size()>0; if (element.size() > 0) { WebElement cancelpopup = element.get(0); cancelpopup.click(); } //driver.switchTo().window(parent); waitForPageLoad(30); Thread.sleep(500); }
From source file:com.digi.selenium.util.common.PageNavigation.java
/** * Handle hyperlink on page by link text * pass the input data /* w w w .ja v a2s . c om*/ * @param Wedriver localWebDeriver * @param String elementID * @param String inputData * @throws Exception */ protected void handleLink_ByText(String linkText) { // try{ getDriver().findElement(By.linkText(linkText)).click(); /*} catch(Exception e) { //System.out.println("Fail : Link Element '" + linkText + "' Click action Failed"); log.error("Fail : Link Element '" + linkText + "' Click action Failed"); throw(e); }*/ }
From source file:com.digi.selenium.util.PageNavigation.java
/** * Handle hyperlink on page by link text * pass the input data //from www . j a v a 2 s. co m * @param Wedriver localWebDeriver * @param String elementID * @param String inputData */ protected void handleLink_ByText(String linkText) { try { getDriver().findElement(By.linkText(linkText)).click(); } catch (Exception e) { //System.out.println("Fail : Link Element '" + linkText + "' Click action Failed"); log.error("Fail : Link Element '" + linkText + "' Click action Failed"); } }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void findByLinkText() { WebElement element = driver.findElement(By.linkText("Text of link")); Assert.assertEquals("Text of link", element.getText()); }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void findElementsByLinkText() { List<WebElement> findElements = driver.findElements(By.linkText("Text of link")); Assert.assertEquals(1, findElements.size()); findElements = driver.findElements(By.linkText("Other link")); Assert.assertEquals(2, findElements.size()); }