List of usage examples for org.openqa.selenium By className
public static By className(String className)
From source file:com.hotwire.test.steps.seo.SeoModelWebApp.java
License:Open Source License
@Override public void verifyDestinationLinks(String source) { if (source.trim().equals("destination")) { // Verify the first couple links as these are dynamically generated and if one of the links is broken, // then all of them will be broken. for (int i = 0; i < MAX_PAGE_CHECKS; i++) { String href = destinationList.get(i); LOGGER.info("HREF: " + href); assertThat(StringUtils.containsAny(href, UNFRIENDLY_SEO_CHARS)).isFalse(); webdriver.navigate().to(href); assertThat(// ww w . j a v a 2s . co m webdriver.findElement(By.className("landingPageTitle")).getText().contains("Hotel Deals")) .isTrue(); } } else { // Top 100. Check all links for SEO unfriendly characters, but only check up to the max checks for the // destination page. int i = 0; for (String href : top100) { LOGGER.info("HREF: " + href); assertThat(StringUtils.containsAny(href, UNFRIENDLY_SEO_CHARS)).isFalse(); if (i < MAX_PAGE_CHECKS) { webdriver.navigate().to(href); assertThat(webdriver.findElement(By.className("landingPageTitle")).getText() .contains("Hotel " + "Deals")).isTrue(); } i++; } } }
From source file:com.htmlhifive.pitalium.it.assertion.exclude.CompareWithExcludesTest.java
License:Apache License
/** * ???????????exclude?<br>/*from w w w . ja va2s. co m*/ * ??????<br> * IE711/FireFox/Chrome/Android 2.3, 4.0, 4.4, 5.1/iOS 8.1, 8.3<br> * ???? */ @Test public void excludeForBodyWithoutScroll() { String platformName = capabilities.getPlatformName(); if (!"ios".equalsIgnoreCase(platformName) && !"android".equalsIgnoreCase(platformName)) { driver.manage().window().setSize(new Dimension(1280, 2500)); } driver.get(URL_TOP_PAGE); PtlWebDriverWait wait = new PtlWebDriverWait(driver, 30); wait.untilLoad(); if (PtlTestConfig.getInstance().getEnvironment().getExecMode() == ExecMode.RUN_TEST) { wait.until(ExpectedConditions.presenceOfElementLocated(By.className("fb-like-box"))); driver.executeJavaScript( "document.getElementsByClassName('fb-like-box')[0].style.backgroundColor='red'"); } CompareTarget[] targets = { new CompareTarget(ScreenArea.of(SelectorType.TAG_NAME, "body"), EXCLUDES, true) }; assertionView.assertView("topPage", targets, HIDDEN_ELEMENTS); }
From source file:com.huangyunkun.jviff.parser.SelectStepParserTest.java
License:Apache License
@Test public void shouldParseScript() throws Exception { Step step = parser.parse("select .colorSelect yellow record"); assertThat(step.getAction(), is(StepAction.SELECT)); assertThat(step.getContent(), is("yellow")); assertThat(step.getTarget(), is(By.className("colorSelect"))); assertThat(step.getRecord(), is(true)); }
From source file:com.ibm.sbt.automation.core.test.pageobjects.SampleFrameworkResultPage.java
License:Open Source License
/** * Return a leaf node. Useful for testing if a click on the leaf node works. * @return {WebElement}// www . jav a 2s . co m */ public WebElement getTreeLeaf() { List<WebElement> leafNodes = getWebElement().findElements(By.className(LEAFNODECLASS)); if (leafNodes.size() == 0) { getExpandAllButton().click(); leafNodes = getWebElement().findElements(By.className(LEAFNODECLASS)); } return leafNodes.get(0); }
From source file:com.ibm.watson.app.qaclassifier.selenium.CommonFunctions.java
License:Open Source License
public static String getDisplayedQuestionText(WebDriver driver) { return driver.findElement(By.className("question-text")).getText(); }
From source file:com.ibm.watson.app.qaclassifier.selenium.CommonFunctions.java
License:Open Source License
public static String getDisplayedAnswerText(WebDriver driver) { return driver.findElement(By.className("answer-quote")).getText(); }
From source file:com.ibm.watson.app.qaclassifier.selenium.CommonFunctions.java
License:Open Source License
public static WebElement findNoneOfTheAboveButton(WebDriver driver) { return driver.findElement(By.className("none")); }
From source file:com.ibm.watson.app.qaclassifier.selenium.CommonFunctions.java
License:Open Source License
public static WebElement findVisitTheForumButton(WebDriver driver) { return driver.findElement(By.className("visitForum")); }
From source file:com.ibm.watson.app.qaclassifier.selenium.FeedbackScreensIT.java
License:Open Source License
@Test public void thisWasHelpfulAllowsNewInput() { CommonFunctions.askQuestionViaTextInput(driver, SampleQuestions.HIGH_CONFIDENCE); assertTrue("After asking question via text input, find answer text on answer page", CommonFunctions.getDisplayedAnswerText(driver).length() > 0); WebElement positiveFeedbackButton = driver.findElement(By.id("positiveFeedbackInput")); if (positiveFeedbackButton.isDisplayed()) { positiveFeedbackButton.click();/* www. j a v a 2 s. c o m*/ } assertThat("After 'This was Helpful' button was pressed, thanks message is displayed", driver.findElements(By.className("thanksImage")), hasSize(1)); if (!CommonFunctions.isMobileUI(driver) && !CommonFunctions.isTabletUI(driver)) { assertThat( "After 'This was Helpful' button was pressed, text input could not be made for another question", driver.findElements(By.id("questionInputField")), hasSize(1)); assertThat( "After 'This was Helpful' button was pressed, text input could not be made for another question", driver.findElements(By.id("askButton")), hasSize(1)); } }
From source file:com.ibm.watson.app.qaclassifier.selenium.FeedbackScreensIT.java
License:Open Source License
@Test public void iStillNeedHelpShowsProperly() { CommonFunctions.askQuestionViaTextInput(driver, SampleQuestions.HIGH_CONFIDENCE); assertTrue("After asking question via text input, find answer text on answer page", CommonFunctions.getDisplayedAnswerText(driver).length() > 0); WebElement negativeFeedbackButton = driver.findElement(By.id("negativeFeedbackInput")); if (negativeFeedbackButton.isDisplayed()) { negativeFeedbackButton.click();/*from w w w . j a va 2 s. com*/ } assertThat("After 'I still need help' button was pressed, 'Refine my question' section is displayed", driver.findElements(By.className("refineQuestion")), hasSize(1)); assertThat("After 'I still need help' button was pressed, 'Still need help?' section is displayed", driver.findElements(By.className("stillNeedHelp")), hasSize(1)); if (!CommonFunctions.isMobileUI(driver)) { assertThat( "After 'I still need help' button was pressed, text input could not be made for another question", driver.findElements(By.id("questionInputField")), hasSize(1)); assertThat( "After 'I still need help' button was pressed, text input could not be made for another question", driver.findElements(By.id("askButton")), hasSize(1)); } }