List of usage examples for org.openqa.selenium By partialLinkText
public static By partialLinkText(String partialLinkText)
From source file:io.fabric8.selenium.forge.ProjectsPage.java
License:Apache License
/** * Creates a new project using the create projects wizard and asserts it appears on the projects page *//* w ww .j av a 2s . co m*/ public void createProject(NewProjectFormData form) { goToProjectsPage(); WebDriverFacade facade = getFacade(); facade.untilLinkClicked(createProjectBy); By nextButton = By.xpath("//button[@ng-click='execute()']"); // it can take a while to load pages in the wizard to lets increase the wait time lots! :) facade.setDefaultTimeoutInSeconds(60 * 9); String named = form.getNamed(); facade.form().clearAndSendKeys(By.xpath("//input[@ng-model='entity.named']"), named). // TODO enter Type //clearAndSendKeys(By.xpath("//label[text() = 'Type']/following::input[@type='text']"), form.getNamed()). submitButton(nextButton).submit(); facade.form().completeComboBox(By.xpath("//label[text() = 'Archetype']/following::input[@type='text']"), form.getArchetypeFilter()).submitButton(nextButton).submit(); untilNextWizardPage(facade, nextButton); facade.form().submitButton(nextButton).submit(); untilNextWizardPage(facade, nextButton); facade.form().completeComboBox(By.xpath("//label[text() = 'Flow']/following::input[@type='text']"), form.getJenkinsFileFilter()).submitButton(nextButton).submit(); facade.untilIsDisplayed(By.xpath("//a[@href='/forge/repos' and text()='Done']")); logInfo("Created project: " + named); goToProjectsPage(); // lets assert there's a link to the project page facade.untilIsDisplayed(By.partialLinkText(named)); }
From source file:io.github.blindio.prospero.core.utils.BySeleneseLocator.java
License:Apache License
public static By seleneseLocator(String seleneseLocator) throws ProsperoUnsupportedLocatorException { By parsedBy = null;/*from w w w .j a v a 2s .c o m*/ int index = seleneseLocator.indexOf(EQUALS_SYMBOL_CODE_POINT); String strategy = null; String locator = null; if (index != -1) { strategy = seleneseLocator.substring(0, index); locator = seleneseLocator.substring(index + 1); if (!(strategy.equalsIgnoreCase(STRATEGY_IDENTIFIER) || strategy.equalsIgnoreCase(STRATEGY_ID) || strategy.equalsIgnoreCase(STRATEGY_NAME) || strategy.equalsIgnoreCase(STRATEGY_DOM) || strategy.equalsIgnoreCase(STRATEGY_XPATH) || strategy.equalsIgnoreCase(STRATEGY_LINK) || strategy.equalsIgnoreCase(STRATEGY_CSS) || strategy.equalsIgnoreCase(STRATEGY_UI))) { strategy = null; } } if (strategy == null) { locator = seleneseLocator; if (seleneseLocator.substring(0, IMPLICIT_STRATEGY_DOM.length()).toLowerCase() .equals(IMPLICIT_STRATEGY_DOM)) { strategy = STRATEGY_DOM; } else if (seleneseLocator.substring(0, IMPLICIT_STRATEGY_XPATH.length()) .equals(IMPLICIT_STRATEGY_XPATH)) { strategy = STRATEGY_XPATH; } else { strategy = STRATEGY_IDENTIFIER; } } if (strategy.equalsIgnoreCase(STRATEGY_IDENTIFIER)) { parsedBy = new ByIdOrName(locator); } else if (strategy.equalsIgnoreCase(STRATEGY_ID)) { parsedBy = By.id(locator); } else if (strategy.equalsIgnoreCase(STRATEGY_NAME)) { parsedBy = By.name(locator); // TODO: use ByChained to parse element-filters } else if (strategy.equalsIgnoreCase(STRATEGY_DOM)) { parsedBy = null; throw new ProsperoUnsupportedLocatorException("Selenium 1.x Locator Strategy: " + STRATEGY_DOM + " is not supported in Webdriver. Selenium recommend using the " + STRATEGY_XPATH + " strategy (" + seleneseLocator + ")"); } else if (strategy.toLowerCase().equals(STRATEGY_XPATH)) { if (locator.endsWith("/")) { parsedBy = By.xpath(locator.substring(0, locator.length() - 1)); } else { parsedBy = By.xpath(locator); } } else if (strategy.equalsIgnoreCase(STRATEGY_LINK)) { parsedBy = By.partialLinkText(seleneseLocator); } else if (strategy.equalsIgnoreCase(STRATEGY_CSS)) { parsedBy = By.cssSelector(locator); } else if (strategy.equalsIgnoreCase(STRATEGY_UI)) { parsedBy = null; throw new ProsperoUnsupportedLocatorException("Selenium 1.x Locator Strategy: " + STRATEGY_UI + " is not supported in Webdriver (" + seleneseLocator + ")"); } else { // TODO } return parsedBy; }
From source file:io.kahu.hawaii.cucumber.glue.html.HtmlSteps.java
License:Apache License
@When("^I click on link with text containing \"([^\"]*)\"$") public void I_click_on_link_with_text_containing(String linkText) throws Throwable { WebElement element = findVisibleElement(By.partialLinkText(linkText)); moveTo(element).click().perform();/* www . ja v a2 s . c o m*/ }
From source file:io.selendroid.demo.webui.EmployeeDirectoryTest.java
License:Apache License
@Step("Find employee <name> with id <id>") public void findEmployee(String name, String id) throws Exception { WebDriver driver = Driver.webDriver; driver.findElement(By.tagName("input")).sendKeys(name); driver.findElement(By.partialLinkText(name)).click(); Assert.assertEquals(driver.getCurrentUrl(), "file:///android_asset/www/index.html#employees/" + id); }
From source file:io.selendroid.nativetests.NativeChildElementFindingTest.java
License:Apache License
@Test public void shouldFindChildButtonsByPartialText() throws Exception { openStartActivity();//from www . ja v a2s .c o m WebElement rootElement = driver().findElement(By.id("l10n")); String buttonText = "EN Butto"; List<WebElement> elements = rootElement.findElements(By.partialLinkText(buttonText)); Assert.assertEquals(elements.size(), 1); Assert.assertTrue(elements.get(0).getText().contains(buttonText)); }
From source file:io.selendroid.nativetests.NativeChildElementFindingTest.java
License:Apache License
@Test() public void shouldNotFindChildElementByPartialText() { openStartActivity();//from w w w .j av a2 s .c o m WebElement rootElement = driver().findElement(By.id("l10n")); try { rootElement.findElement(By.partialLinkText("nonExistantButton")); Assert.fail("Should not have succeeded"); } catch (NoSuchElementException e) { // this is expected } }
From source file:io.selendroid.nativetests.NativeChildElementFindingTest.java
License:Apache License
@Test public void shouldFindChildButtonByPartialText() throws Exception { openStartActivity();//from w w w . j ava 2s. c om WebElement rootElement = driver().findElement(By.id("l10n")); String buttonText = "EN Butto"; WebElement clickMe = rootElement.findElement(By.partialLinkText(buttonText)); Assert.assertTrue(clickMe.getText().contains(buttonText)); }
From source file:io.selendroid.nativetests.NativeElementFindingTest.java
License:Apache License
@Test public void shouldFindButtonByPartialText() throws Exception { openStartActivity();/*from w w w . ja v a 2 s .c o m*/ String buttonText = "EN Butto"; WebElement clickMe = driver().findElement(By.partialLinkText(buttonText)); Assert.assertTrue(clickMe.getText().contains(buttonText)); }
From source file:io.selendroid.nativetests.NativeElementFindingTest.java
License:Apache License
@Test public void shouldFindButtonsByPartialText() throws Exception { openStartActivity();/*w w w .ja v a2 s . co m*/ String buttonText = "EN Butto"; List<WebElement> elements = driver().findElements(By.partialLinkText(buttonText)); Assert.assertEquals(elements.size(), 1); Assert.assertTrue(elements.get(0).getText().contains(buttonText)); }
From source file:io.selendroid.nativetests.NativeElementFindingTest.java
License:Apache License
@Test() public void shouldNotFindElementByPartialText() { openStartActivity();//from ww w . ja va2 s. c om try { driver().findElement(By.partialLinkText("nonExistentButton")); Assert.fail("Should not have succeeded"); } catch (NoSuchElementException e) { // this is expected } }