List of usage examples for org.openqa.selenium By partialLinkText
public static By partialLinkText(String partialLinkText)
From source file:io.selendroid.webviewdrivertests.WebElementFindingTest.java
License:Apache License
@Test public void shouldFindElementsByPartialText() throws Exception { openWebdriverTestPage(HtmlTestData.XHTML_TEST_PAGE); WebElement clickMe = driver().findElements(By.partialLinkText("click m")).get(0); clickMe.click();//from w w w . j a v a 2 s .c o m waitFor(pageTitleToBe(driver(), "We Arrive Here"), 15, TimeUnit.SECONDS); Assert.assertEquals(driver().getTitle(), "We Arrive Here"); }
From source file:jp.co.nssol.h5.test.selenium.base.H5TestCase.java
License:Apache License
protected static List<WebElement> getElementsByPartialLinkText(String linkText, WebElement targetElement) { List<WebElement> findElement = null; if (targetElement instanceof WebElement) { findElement = targetElement.findElements(By.partialLinkText(linkText)); } else {/*from w w w .ja v a2 s . co m*/ findElement = driver.findElements(By.partialLinkText(linkText)); } return findElement; }
From source file:net.integration.StartPage.java
License:Open Source License
public NamespacePage goToNamespacePage(String namespaceName) { WebElement webElement = webDriver.findElement(By.partialLinkText(namespaceName)); webElement.click();/*from w w w .jav a2 s.c om*/ pause(500); return new NamespacePage(webDriver); }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
private By buildFromFindBy(FindBy findBy) { if (!"".equals(findBy.className())) { return By.className(findBy.className()); }//from w ww . j ava 2 s .c o m if (!"".equals(findBy.css())) { return By.cssSelector(findBy.css()); } if (!"".equals(findBy.id())) { return By.id(findBy.id()); } if (!"".equals(findBy.linkText())) { return By.linkText(findBy.linkText()); } if (!"".equals(findBy.name())) { return By.name(findBy.name()); } if (!"".equals(findBy.partialLinkText())) { return By.partialLinkText(findBy.partialLinkText()); } if (!"".equals(findBy.tagName())) { return By.tagName(findBy.tagName()); } if (!"".equals(findBy.xpath())) { return By.xpath(findBy.xpath()); } // Fall through return null; }
From source file:org.alfresco.po.share.UserSearchPage.java
License:Open Source License
/** * Clicks on given userName present in userSearch List and it opens the User profile page. * //from w w w. j a v a 2 s . c o m * @return UserProfilePage */ public HtmlPage clickOnUser(String userName) { if (StringUtils.isEmpty(userName)) { throw new IllegalArgumentException("user name is required"); } By link = By.partialLinkText(userName); driver.findElement(link).click(); //check link has gone driver.findElements(link); return factoryPage.instantiatePage(driver, UserProfilePage.class); }
From source file:org.apache.zeppelin.integration.AuthenticationIT.java
License:Apache License
public void testSimpleAuthentication() throws Exception { try {/* ww w . j ava 2s . com*/ AuthenticationIT authenticationIT = new AuthenticationIT(); authenticationIT.authenticationUser("admin", "password1"); collector.checkThat("Check is user logged in", true, CoreMatchers.equalTo(driver.findElement(By.partialLinkText("Create new note")).isDisplayed())); authenticationIT.logoutUser("admin"); } catch (Exception e) { handleException("Exception in AuthenticationIT while testCreateNewButton ", e); } }
From source file:org.apache.zeppelin.ZeppelinIT.java
License:Apache License
private WebDriver getWebDriver() { WebDriver driver = null;//from w ww .j a v a 2s . c o m if (driver == null) { try { FirefoxBinary ffox = new FirefoxBinary(); if ("true".equals(System.getenv("TRAVIS"))) { ffox.setEnvironmentProperty("DISPLAY", ":99"); // xvfb is supposed to // run with DISPLAY 99 } FirefoxProfile profile = new FirefoxProfile(); driver = new FirefoxDriver(ffox, profile); } catch (Exception e) { } } if (driver == null) { try { driver = new ChromeDriver(); } catch (Exception e) { } } if (driver == null) { try { driver = new SafariDriver(); } catch (Exception e) { } } String url; if (System.getProperty("url") != null) { url = System.getProperty("url"); } else { url = "http://localhost:8080"; } long start = System.currentTimeMillis(); boolean loaded = false; driver.get(url); while (System.currentTimeMillis() - start < 60 * 1000) { // wait for page load try { (new WebDriverWait(driver, 5)).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { return d.findElement(By.partialLinkText("Create new note")).isDisplayed(); } }); loaded = true; break; } catch (TimeoutException e) { driver.navigate().to(url); } } if (loaded == false) { fail(); } return driver; }
From source file:org.apache.zeppelin.ZeppelinIT.java
License:Apache License
@Test public void testAngularDisplay() throws InterruptedException { if (!endToEndTestEnabled()) { return;//from w ww .j a va 2 s. co m } String noteName = createNewNoteAndGetName(); driver.findElement(By.partialLinkText(noteName)).click(); // wait for first paragraph's " READY " status text waitForParagraph(1, "READY"); /* * print angular template * %angular <div id='angularTestButton' ng-click='myVar=myVar+1'>BindingTest_{{myVar}}_</div> */ WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")); paragraph1Editor.sendKeys("println" + Keys.chord(Keys.SHIFT, "9") + "\"" + Keys.chord(Keys.SHIFT, "5") + "angular <div id='angularTestButton' " + "ng" + Keys.chord(Keys.SUBTRACT) + "click='myVar=myVar+1'>" + "BindingTest_{{myVar}}_</div>\")"); paragraph1Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(1, "FINISHED"); // check expected text assertEquals("BindingTest__", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText()); /* * Bind variable * z.angularBind("myVar", 1) */ assertEquals(1, driver.findElements(By.xpath(getParagraphXPath(2) + "//textarea")).size()); WebElement paragraph2Editor = driver.findElement(By.xpath(getParagraphXPath(2) + "//textarea")); paragraph2Editor.sendKeys("z.angularBind" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\", 1)"); paragraph2Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(2, "FINISHED"); // check expected text assertEquals("BindingTest_1_", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText()); /* * print variable * print("myVar="+z.angular("myVar")) */ WebElement paragraph3Editor = driver.findElement(By.xpath(getParagraphXPath(3) + "//textarea")); paragraph3Editor.sendKeys("print" + Keys.chord(Keys.SHIFT, "9") + "\"myVar=\"" + Keys.chord(Keys.ADD) + "z.angular" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\"))"); paragraph3Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(3, "FINISHED"); // check expected text assertEquals("myVar=1", driver.findElement(By.xpath(getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]")) .getText()); /* * Click element */ driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); // check expected text assertEquals("BindingTest_2_", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText()); /* * Register watcher * z.angularWatch("myVar", (before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext) => { * z.run(2, context) * } */ WebElement paragraph4Editor = driver.findElement(By.xpath(getParagraphXPath(4) + "//textarea")); paragraph4Editor.sendKeys( "z.angularWatch" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\", " + Keys.chord(Keys.SHIFT, "9") + "before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext)" + Keys.EQUALS + ">{ z.run" + Keys.chord(Keys.SHIFT, "9") + "2, context)}"); paragraph4Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(4, "FINISHED"); /* * Click element, again and see watcher works */ driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click(); // check expected text assertEquals("BindingTest_3_", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText()); waitForParagraph(3, "FINISHED"); // check expected text by watcher assertEquals("myVar=3", driver.findElement(By.xpath(getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]")) .getText()); /* * Unbind * z.angularUnbind("myVar") */ WebElement paragraph5Editor = driver.findElement(By.xpath(getParagraphXPath(5) + "//textarea")); paragraph5Editor.sendKeys("z.angularUnbind" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\")"); paragraph5Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(5, "FINISHED"); // check expected text assertEquals("BindingTest__", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText()); /* * Bind again and see rebind works. */ paragraph2Editor = driver.findElement(By.xpath(getParagraphXPath(2) + "//textarea")); paragraph2Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER)); waitForParagraph(2, "FINISHED"); // check expected text assertEquals("BindingTest_1_", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText()); System.out.println("testCreateNotebook Test executed"); }
From source file:org.apache.zeppelin.ZeppelinIT.java
License:Apache License
private String createNewNoteAndGetName() { List<WebElement> notebookLinks = driver .findElements(By.xpath("//div[contains(@class, \"col-md-4\")]/div/ul/li")); List<String> notebookTitles = new LinkedList<String>(); for (WebElement el : notebookLinks) { notebookTitles.add(el.getText()); }//from ww w .ja v a 2 s . co m WebElement createNoteLink = driver.findElement(By.partialLinkText("Create new note")); createNoteLink.click(); try { Thread.sleep(500); // wait for notebook list updated } catch (InterruptedException e) { } List<WebElement> notebookLinksAfterCreate = driver .findElements(By.xpath("//div[contains(@class, \"col-md-4\")]/div/ul/li")); Iterator<WebElement> it = notebookLinksAfterCreate.iterator(); while (it.hasNext()) { WebElement newEl = it.next(); if (notebookTitles.contains(newEl.getText())) { it.remove(); } } assertEquals(1, notebookLinksAfterCreate.size()); return notebookLinksAfterCreate.get(0).getText(); }
From source file:org.auraframework.integration.test.components.ui.tabset.TabsetUITest.java
License:Apache License
/** * Verifying that nestedTabs work the same as normal tabs *//* w w w . j av a 2s . co m*/ @Test public void testNestedTabsDelete() throws Exception { open(createURL("nestedTabs", "false")); WebElement el = findDomElement(By.partialLinkText("inner tab 1")); el.click(); el = findDomElement(By.xpath("//li/a/a")); el.click(); // Verify nested tab that was not deleted is active verifyElementIsActive(By.xpath("//li[contains(., 'inner tab 2')]")); // Verify that the parent tab is still active, and that both elements in the parents tabBar still exist verifyElementIsActive(By.xpath("//li[contains(., 'tab1')]")); List<WebElement> elements = findDomElements(By.xpath("//div[contains(@class,'nestedTabs')]/div/ul/li")); assertEquals("Size of the part tabBar was not as expected. Something must have been deleted", 2, elements.size()); }