List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:com.sonar.it.jenkins.orchestrator.JenkinsOrchestrator.java
License:Open Source License
public void assertNoSonarPublisher(String jobName, File projectPath) { newFreestyleJobConfig(jobName, projectPath); WebElement addPostBuildButton = findElement(buttonByText("Add post-build action")); scrollTo(addPostBuildButton);/*from w ww. ja v a 2s . c o m*/ addPostBuildButton.click(); findElement(By.linkText("SonarQube analysis with Maven")).click(); assertNoElement(By.xpath("//div[@descriptorid='hudson.plugins.sonar.SonarPublisher']")); findElement(buttonByText("Save")).click(); }
From source file:com.sugarcrm.candybean.automation.control.VControl.java
License:Open Source License
protected static By makeBy(Strategy strategy, String hook) throws Exception { switch (strategy) { case CSS: return By.cssSelector(hook); case XPATH:/*from w w w . ja v a2 s.c o m*/ return By.xpath(hook); case ID: return By.id(hook); case NAME: return By.name(hook); case LINK: return By.linkText(hook); case PLINK: return By.partialLinkText(hook); case CLASS: return By.className(hook); case TAG: return By.tagName(hook); default: throw new Exception("Selenium: strategy type not recognized."); } }
From source file:com.sugarcrm.candybean.automation.element.Hook.java
License:Open Source License
/** * A helper method to convert Hook to By * @param hook The hook that specifies a web element * @return The converted By//from w ww. j a va 2 s. co m * @throws CandybeanException */ public static By getBy(Hook hook) throws CandybeanException { switch (hook.hookStrategy) { case CSS: return By.cssSelector(hook.hookString); case XPATH: return By.xpath(hook.hookString); case ID: return By.id(hook.hookString); case NAME: return By.name(hook.hookString); case LINK: return By.linkText(hook.hookString); case PLINK: return By.partialLinkText(hook.hookString); case CLASS: return By.className(hook.hookString); case TAG: return By.tagName(hook.hookString); default: throw new CandybeanException("Strategy type not recognized."); } }
From source file:com.sugarcrm.candybean.automation.webdriver.WebDriverElement.java
License:Open Source License
public static By By(Strategy strategy, String hookString) throws CandybeanException { switch (strategy) { case CSS: return By.cssSelector(hookString); case XPATH:/*from w w w.jav a2 s . com*/ return By.xpath(hookString); case ID: return By.id(hookString); case NAME: return By.name(hookString); case LINK: return By.linkText(hookString); case PLINK: return By.partialLinkText(hookString); case CLASS: return By.className(hookString); case TAG: return By.tagName(hookString); default: throw new CandybeanException("Strategy type not recognized."); } }
From source file:com.surevine.alfresco.space.webdriver.SpaceDashboard.java
License:Open Source License
public SiteDashBoard navigateToSite(final String siteName) { WebElement site = driver.findElement(By.linkText(siteName)); site.click();/*from w w w .j a v a 2 s .c o m*/ return new SiteDashBoard(driver); }
From source file:com.technophobia.webdriver.substeps.impl.ActionWebDriverSubStepImplementations.java
License:Open Source License
/** * Click the link "(....)" as it appears on the page * /*from w ww . ja va2 s.com*/ * @example ClickLink "Contracts" * @section Clicks * @param linkText * the link text */ @Step("ClickLink \"([^\"]*)\"") public void clickLink(final String linkText) { logger.debug("About to click link with text " + linkText); webDriverContext().setCurrentElement(null); final WebElement elem = webDriver().findElement(By.linkText(linkText)); Assert.assertNotNull("expecting to find a link: " + linkText, elem); webDriverContext().setCurrentElement(elem); elem.click(); }
From source file:com.technophobia.webdriver.substeps.impl.TableSubStepImplementations.java
License:Open Source License
/** * Find a link (anchor) element within a table row using the link text as a * discriminator.//from w w w .j a v a 2 s. c om * * @example FindElementInRow linkText="View" * @section Table * @param linkText * the text of the link to find */ @Step("FindElementInRow linkText=\"([^\"]*)\"") public void findLinkInRow(final String linkText) { final By by = By.linkText(linkText); findElementInRowBy(by); }
From source file:com.testmax.handler.SeleniumBaseHandler.java
License:CDDL license
protected By getBy() throws NumberFormatException, TestMaxException { this.controlIdentifier = ""; for (Object key : primary.keySet()) { String[] attrs = primary.get(key.toString()).split("#"); for (String attr : attrs) { this.setImpilicitTimeInMiliSec(new Integer(timeout + 1000)); if (key.toString().equalsIgnoreCase("id")) { this.controlIdentifier = attr; if (this.isElementDisplayed(By.id(attr)) || isBypassDisplay() && isElementPresent(By.id(attr))) { return By.id(attr); }//from w w w . j a va 2s. com } else if (key.toString().equalsIgnoreCase("name")) { this.controlIdentifier = attr; if (this.isElementDisplayed(By.name(attr))) { return By.name(attr); } } else if (key.toString().equalsIgnoreCase("classname")) { this.controlIdentifier = attr; if (this.isElementDisplayed(By.className(attr))) { return By.className(attr); } } else if (key.toString().equalsIgnoreCase("cssSelector")) { this.controlIdentifier = attr; if (this.isElementDisplayed(By.cssSelector(attr))) { return By.cssSelector(attr); } } else if (key.toString().equalsIgnoreCase("linkText")) { this.controlIdentifier = attr; if (this.isElementDisplayed(By.linkText(attr))) { return By.linkText(attr); } } else if (key.toString().equalsIgnoreCase("xpath")) { this.controlIdentifier = attr; //if(this.isElementDisplayed(By.xpath(attr))){ return By.xpath(attr); //} } else if (key.toString().equalsIgnoreCase("tagname")) { this.controlIdentifier = attr; return By.tagName(attr); } } //printMessage("****ERROR : No ATTRIBUTE matching for the Primary Element= "+this.tagdesc); } return null; }
From source file:com.testmax.handler.SeleniumBaseHandler.java
License:CDDL license
protected HashMap<String, By> getByFromAttribute() { HashMap<String, By> bys = new HashMap<String, By>(); String[] attrlist = this.havingAttribute.split("#"); for (String attrelm : attrlist) { By by = null;/* w w w . j a v a 2 s . c o m*/ if (attrelm.split("::")[0].equals("id") && attrelm.split("::").length > 1) { by = By.id(attrelm.split("::")[1]); this.printMessage("****LOCATED attribute id=" + attrelm.split("::")[1] + " for tag with havingAttribute=" + this.havingAttribute); //return by; bys.put("id", by); } else if (attrelm.split("::")[0].equals("name")) { by = By.name(attrelm.split("::")[1]); this.printMessage("****LOCATED attribute name=" + attrelm.split("::")[1] + " for tag with havingAttribute=" + this.havingAttribute); //return by; bys.put("name", by); } else if (attrelm.split("::")[0].equals("class")) { by = By.className(attrelm.split("::")[1]); this.printMessage("****LOCATED attribute class=" + attrelm.split("::")[1] + " for tag with havingAttribute=" + this.havingAttribute); //return by; bys.put("class", by); } else if (this.tagName.equals("a") && attrelm.split("::")[0].equals("text")) { by = By.linkText(attrelm.split("::")[1]); this.printMessage("****LOCATED attribute text=" + attrelm.split("::")[1] + " for tag with havingAttribute=" + this.havingAttribute); bys.put("text", by); //return by; } else if (this.tagName.equals("a") && attrelm.split("::")[0].equals("text")) { by = By.partialLinkText(attrelm.split("::")[1]); this.printMessage("****LOCATED attribute text=" + attrelm.split("::")[1] + " for tag with havingAttribute=" + this.havingAttribute); //return by; bys.put("a", by); } else if (attrelm.split("::")[0].equals("xpath")) { String xpath = attrelm.split("::")[1]; xpath = xpath.replaceAll("!", "'"); by = By.xpath(xpath); this.printMessage("****LOCATED attribute xpath=" + attrelm.split("::")[1] + " for tag with havingAttribute=" + this.havingAttribute); //return by; bys.put("xpath", by); } else if (attrelm.split("::")[0].equals("css")) { by = By.cssSelector(attrelm.split("::")[1]); this.printMessage("****LOCATED attribute css=" + attrelm.split("::")[1] + " for tag with havingAttribute=" + this.havingAttribute); bys.put("css", by); //return by; } } if (this.tagName.contains(".")) { By by = By.cssSelector(this.tagName); bys.put("css", by); this.printMessage( "****LOCATED attribute cssSelector=" + this.tagName + " for tag with tagname=" + this.tagName); } else if (!this.isEmptyValue(id)) { By by = By.id(this.id); bys.put("id", by); } return bys; }
From source file:com.testprojectcdb.codebase.HomeScreen.java
public EditDeleteComputerScreen navigateToTheEditComputerScreen(String name, Date introDate, Date disConDate, String company) throws ParseException { int rowNum = verifyFilteredCompDetailsDisplay(name, introDate, disConDate, company); driver.findElement(By.xpath(String.format("//*[@id=\"main\"]/table/tbody/tr[%s]/td[1]", rowNum))) .findElement(By.linkText(name)).click(); return new EditDeleteComputerScreen(); }