List of usage examples for org.openqa.selenium By partialLinkText
public static By partialLinkText(String partialLinkText)
From source file:com.java.AppTestType_18_11_2015.java
public void EXACTBIDFROMWATCHINGPAGE(WebDriver driver) { try {/*from w w w. ja va 2 s . c o m*/ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.navigate().to("http://e1.dev.assetnation.com/all-equipment/equipmentone-listings"); WebDriverWait wait = new WebDriverWait(driver, 25); Thread.sleep(1000); //navigation to next page driver.findElement(By.linkText("2")).click(); //Thread.sleep(5000) wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]"))); //clicking on first binocular icon which is not yet watching driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]")).click(); //Thread.sleep(5000); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("(//a[text()='MyONE '])[2]"))); driver.findElement(By.xpath("(//a[text()='MyONE '])[2]")).click(); //Thread.sleep(5000); wait.until(ExpectedConditions.presenceOfElementLocated(By.partialLinkText("Watching"))); driver.findElement(By.partialLinkText("Watching")).click(); if (wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]"))) .isDisplayed()) { driver.findElement(By.xpath("(//*[@type='radio' and @value='Exact Bid'])[2]")).click(); Thread.sleep(4000); driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click(); BIDDING_IN_LISTINGDETAILSPAGE(driver); resultDetails.setFlag(true); } else { System.out.println("there is no place a bid button in watchlist section"); } } catch (Exception e) { e.printStackTrace(); resultDetails.setErrorMessage("Listing is not available or Closed"); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void MAXBIDFROMWATCHINGPAGE(WebDriver driver) { try {/*from w w w . ja v a2 s . c om*/ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.navigate().to("http://e1.dev.assetnation.com/all-equipment/equipmentone-listings"); WebDriverWait wait = new WebDriverWait(driver, 25); Thread.sleep(1000); //navigation to next page driver.findElement(By.linkText("2")).click(); //Thread.sleep(5000) wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]"))); //clicking on first binocular icon which is not yet watching driver.findElement(By.xpath("(//*[@class='e1tooltip icon_watchlist'])[1]")).click(); //Thread.sleep(5000); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("(//a[text()='MyONE '])[2]"))); driver.findElement(By.xpath("(//a[text()='MyONE '])[2]")).click(); //Thread.sleep(5000); wait.until(ExpectedConditions.presenceOfElementLocated(By.partialLinkText("Watching"))); driver.findElement(By.partialLinkText("Watching")).click(); if (wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]"))) .isDisplayed()) { driver.findElement(By.xpath("(//*[contains(@value,'PLACE A BID')])[2]")).click(); BIDDING_IN_LISTINGDETAILSPAGE(driver); resultDetails.setFlag(true); } else { System.out.println("there is no 'place a bid button' in watchlist section"); } } catch (Exception e) { e.printStackTrace(); resultDetails.setErrorMessage("Listing is not available or Closed"); resultDetails.setFlag(false); } }
From source file:com.java.AppTestType_18_11_2015.java
public void VERIFYNOT(WebDriver driver, String fieldText, String value) { //To verify that the locator doesn't exist //FieldText---Locator //value----Time in ms //Give lesser Time like 2000,or else the execution will wait that much time try {/*from www .jav a2 s . c om*/ String f = fieldText; String time = value; String locatorType = f.substring(0, 3); String locatorValue = f.substring(3, f.length()); int timevalue = Integer.parseInt(time); driver.manage().timeouts().implicitlyWait(timevalue, TimeUnit.MILLISECONDS); if (locatorType.equalsIgnoreCase("XPH")) { if (driver.findElements(By.xpath(locatorValue)).size() == 0) resultDetails.setFlag(true); } else if (locatorType.equalsIgnoreCase("LNK")) { if (driver.findElements(By.linkText(locatorValue)).size() == 0) resultDetails.setFlag(true); } else if (locatorType.equalsIgnoreCase("IDI") || locatorType.equalsIgnoreCase("TXT")) { if (driver.findElements(By.id(locatorValue)).size() == 0) resultDetails.setFlag(true); } else if (locatorType.equalsIgnoreCase("MSG")) { int j = 0; int t = timevalue / 1000; for (int i = 0; i < t; i++) { if (driver.findElements(By.xpath("//*[contains(text(),'" + locatorValue + "')]")).size() == 0) { j = 1; break; } Thread.sleep(1000); } if (j == 1) resultDetails.setFlag(true); } else if (locatorType.equalsIgnoreCase("PLK")) { if (driver.findElements(By.partialLinkText(locatorValue)).size() == 0) resultDetails.setFlag(true); } } catch (Exception e) { e.printStackTrace(); resultDetails.setErrorMessage("Element is Present"); resultDetails.setFlag(false); } }
From source file:com.joyce.automation.util.prop.Prop.java
License:Apache License
/** * // w ww. j av a2 s. co m * ??:???? * * @param elementNameInProp * ?key(eg:login.username=id>value ) * @author jiaozhongbin * @throws Exception */ public By getLocator(String elementNameInProp) { String locator = properties.getProperty(elementNameInProp); String locatorType = locator.split(Const.DEFAULT_SPLIT)[0]; String locatorValue = locator.split(Const.DEFAULT_SPLIT)[1]; try { // locatorValue = new String(locatorValue.getBytes("ISO-8859-1"), "UTF-8"); if (locatorType.toLowerCase().equals("id")) { return By.id(locatorValue); } else if (locatorType.toLowerCase().equals("xpath")) { return By.xpath(locatorValue); } else if (locatorType.toLowerCase().equals("name")) { return By.name(locatorValue); } else if (locatorType.toLowerCase().equals("classname") || locatorType.toLowerCase().equals("class")) { return By.className(locatorValue); } else if (locatorType.toLowerCase().equals("tagname") || locatorType.toLowerCase().equals("tag")) { return By.tagName(locatorValue); } else if (locatorType.toLowerCase().equals("linktext") || locatorType.toLowerCase().equals("link")) { return By.linkText(locatorValue); } else if (locatorType.toLowerCase().equals("partiallinktext")) { return By.partialLinkText(locatorValue); } else if (locatorType.toLowerCase().equals("cssselector") || locatorType.toLowerCase().equals("css")) { return By.cssSelector(locatorValue); } else log.error("locatorType?:" + locatorType); return null; } catch (IllegalArgumentException e1) { log.error("{" + locatorType + "=" + locatorValue + "}?", e1); } return null; }
From source file:com.mkl.websuites.command.OperationOnWebElement.java
License:Apache License
@Override protected void runCommandWithParameters() { by = null;//from w ww .j av a 2 s .com if (parameterMap.keySet().contains("id")) { by = By.id(parameterMap.get("id")); } if (parameterMap.keySet().contains("css")) { by = By.cssSelector(parameterMap.get("css")); } if (parameterMap.keySet().contains("xpath")) { by = By.xpath(parameterMap.get("xpath")); } if (parameterMap.keySet().contains("className")) { by = By.className(parameterMap.get("className")); } if (parameterMap.keySet().contains("linkText")) { by = By.linkText(parameterMap.get("linkText")); } if (parameterMap.keySet().contains("partialLinkText")) { by = By.partialLinkText(parameterMap.get("partialLinkText")); } if (parameterMap.keySet().contains("name")) { by = By.name(parameterMap.get("name")); } if (parameterMap.keySet().contains("tagName")) { by = By.tagName(parameterMap.get("tagName")); } try { WebElement elem = browser.findElement(by); foundElement = elem; doOperationOnElement(elem); } catch (NoSuchElementException e) { fail("No element found for selecor " + by + " can be found on the page. " + "Selection parameters: " + parameterMap); } }
From source file:com.mkl.websuites.command.OperationOnWebElementTest.java
License:Apache License
@Test public void shouldRunForPartialLinkText(@Mocked final WebDriver browser) { runFor(browser, "partialLinkText", "someParialLinkText", By.partialLinkText("someParialLinkText")); }
From source file:com.mkl.websuites.internal.command.impl.check.CheckLinkTextContaining.java
License:Apache License
@Override protected String getStringParam() { try {/* ww w . ja va2s. c om*/ foundElem = browser.findElement(By.partialLinkText(expectedLinkText)); actualLinkText = foundElem.getText(); } catch (NoSuchElementException e) { return null; } return "OK"; }
From source file:com.moodle.testmanager.pageObjectModel.Courses.java
License:GNU General Public License
/** * Clicks the Add a New Course Button. If there are no courses already it does this from the home page. If there is already a course * the page object locates an alternative Add a new course button. *//*from ww w .java 2 s .com*/ public void clickAddCourse() { driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); boolean itemVisible = false; try { WebElement addCourseButton = driver.findElement( By.cssSelector("input[value='" + this.properties.get("addNewCourseButton") + "']")); itemVisible = addCourseButton.isDisplayed(); } catch (NoSuchElementException ex) { } if (itemVisible) { WebElement addCourseButton = driver.findElement( By.cssSelector("input[value='" + this.properties.get("addNewCourseButton") + "']")); addCourseButton.click(); } else { //WebElement courseTreeItemRoot = driver.findElement(By .partialLinkText(this.properties.get("coursesNavBlock"))); WebElement courseTreeItemRoot = driver .findElement(By.partialLinkText(this.properties.get("coursesNavBlock"))); courseTreeItemRoot.click(); WebElement addCourseButton = driver.findElement( By.cssSelector("input[value='" + this.properties.get("addNewCourseButton") + "']")); addCourseButton.click(); } driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }
From source file:com.moodle.testmanager.pageObjectModel.Courses.java
License:GNU General Public License
/** * Clicks the courses root tree menu item. *//*from w ww.j a va 2s . co m*/ public void clickCoursesInTreeMenu() { WebElement courseTreeItemRoot = driver .findElement(By.partialLinkText("" + this.properties.get("coursesNavBlock") + "")); courseTreeItemRoot.click(); }
From source file:com.moodle.testmanager.pageObjectModel.Courses.java
License:GNU General Public License
/** * Clicks a course item defined in the test in the tree menu. * @param shortName//from www .j av a2s . co m */ public void clickCourseInTreeMenu(String shortName) { WebElement specifiedCourseTreeItem = driver.findElement(By.partialLinkText(shortName)); specifiedCourseTreeItem.click(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }