Пример #1
0
  @Test(dataProvider = "registrationData", dataProviderClass = DataProviders.class)
  public void signUpTes(
      String user, String email, String pass, String emailValidation, String passValidation)
      throws IOException {
    RegisterPage.fillForm(user, email, pass);
    int validations = 0;

    if (emailValidation.length() > 2) {
      validations++;
      WebElement emailValidationElement =
          getDriver().findElement(RegisterPage.ACTIVE_EMAIL_VALIDATION);
      Assert.assertTrue(emailValidationElement.isDisplayed());
      Assert.assertEquals(emailValidationElement.getText(), emailValidation);
    }

    if (passValidation.length() > 2) {
      validations++;
      WebElement passValidationMessage =
          getDriver().findElement(RegisterPage.ACTIVE_PASS_VALIDATION);
      Assert.assertTrue(passValidationMessage.isDisplayed());
      Assert.assertEquals(passValidationMessage.getText(), passValidation);
    }

    Assert.assertEquals(RegisterPage.getValidationMessages().size(), validations);
  }
  public static void main(String[] args) throws Exception {

    IPhoneDriver driver = new IPhoneDriver("http://192.168.0.39:3001/hub/");

    driver.get("http://orangeworld.co.uk/");
    System.out.println(driver.getCurrentUrl());

    WebElement MenuTab = driver.findElementByXPath(Constants.MenuTab);
    MenuTab.isDisplayed();
    MenuTab.click();
    Thread.sleep(3000);
    // Menu Content Entertainment
    WebElement MenuContent_Entertainment =
        driver.findElementByXPath(Constants.MenuContent_Entertainment);
    MenuContent_Entertainment.isDisplayed();
    MenuContent_Entertainment.click();

    WebElement MenuContent_Entertainment_BreadCrumb =
        driver.findElementByXPath(Constants.MenuContent_Entertainment_BreadCrumb);
    MenuContent_Entertainment_BreadCrumb.isDisplayed();
    System.out.println("BreadCrumb Name is " + MenuContent_Entertainment_BreadCrumb.getText());

    WebElement Entertainment_Homepage = driver.findElementByXPath(Constants.Entertainment_Homepage);
    Entertainment_Homepage.isDisplayed();
    Entertainment_Homepage.click();
    System.out.println(driver.getCurrentUrl());

    System.out.println("Test pass");

    driver.quit();
  }
  @Test
  @RunAsClient
  public void testFaceletCompositionCustomTag() throws Exception {
    browser.get(portalURL.toString());

    assertTrue("Check that page contains header element.", header.isDisplayed());
    assertTrue("Check that page contains button element.", buttonCustom.isDisplayed());
  }
Пример #4
0
 public boolean isPresent() {
   try {
     return (webElement != null) && (webElement.isDisplayed() || !webElement.isDisplayed());
   } catch (NoSuchElementException e) {
     if (e.getCause().getMessage().contains("Element is not usable")) {
       return true;
     }
     return false;
   }
 }
Пример #5
0
 public TeamsPage addMemberInTeam(String nameMember, String email) {
   clickAddMembersBtn();
   setEmailMembers(email);
   if (selectAddForm.isDisplayed() && selectAddForm.isEnabled()) {
     clickMemberOptions();
     clickIconClose();
   } else if (fullNameForm.isDisplayed() && fullNameForm.isEnabled()) {
     setNameInvite(nameMember);
     clickSendInvitedMember();
   }
   return this;
 }
 @Override
 public void scrollIntoView(WebElement el) {
   boolean elementInView = el.isDisplayed();
   while (!elementInView) {
     getBrowser().dragUp();
     elementInView = el.isDisplayed();
   }
   HashMap<String, String> scrollObject = new HashMap<String, String>();
   String widId = ((RemoteWebElement) el).getId();
   scrollObject.put("element", widId);
   getBrowser().getWebDriver().executeScript("mobile: scrollTo", scrollObject);
 }
Пример #7
0
  @Test
  public void checkDisplayedOnGoogleSearchBox() {
    WebDriver d = getDriver();

    d.get("http://www.google.com");
    WebElement el = d.findElement(By.cssSelector("input[name*='q']"));

    assertTrue(el.isDisplayed());

    el = d.findElement(By.cssSelector("input[type='hidden']"));

    assertFalse(el.isDisplayed());
  }
Пример #8
0
  @Test
  public void testDynamicSelects() {

    List<String> fruitsExpected = new ArrayList<String>();
    fruitsExpected.add("");
    fruitsExpected.add("Banana");
    fruitsExpected.add("Cranberry");
    fruitsExpected.add("Blueberry");
    fruitsExpected.add("Orange");

    List<String> vegetablesExpected = new ArrayList<String>();
    vegetablesExpected.add("");
    vegetablesExpected.add("Potatoes");
    vegetablesExpected.add("Broccoli");
    vegetablesExpected.add("Garlic");
    vegetablesExpected.add("Carrot");

    assertTrue(firstSelect.isDisplayed(), "First select should be displayed!");

    //        assertFalse(secondSelect.isDisplayed(), "Second select should be dispayed");

    Graphene.guardAjax(new Select(firstSelect)).selectByVisibleText("Fruits");

    List<String> fruitsActual = new ArrayList<String>();
    List<WebElement> fruitsOptions = new Select(secondSelect).getOptions();
    for (WebElement option : fruitsOptions) {
      fruitsActual.add(option.getText().trim());
    }

    assertTrue(secondSelect.isDisplayed(), "Second select should be dispayed");

    assertEquals(
        fruitsActual,
        fruitsExpected,
        "When selected fruits in first select, in the second "
            + "should be some examples of Fruits");

    Graphene.guardAjax(new Select(firstSelect)).selectByVisibleText("Vegetables");

    List<String> vegetablesActual = new ArrayList<String>();
    List<WebElement> vegetablesOptions = new Select(secondSelect).getOptions();
    for (WebElement option : vegetablesOptions) {
      vegetablesActual.add(option.getText().trim());
    }

    assertEquals(
        vegetablesActual,
        vegetablesExpected,
        "When selected vegetables in first select, in the second "
            + "should be some examples of vegetables");
  }
  @Test
  @RunAsClient
  @InSequence(4000)
  public void screenNameColumnFilter() throws Exception {

    waitForElement(browser, screenNameColumnFilterXpath);
    screenNameColumnFilter.sendKeys("john.adams");

    Thread.sleep(1000);

    logger.log(
        Level.INFO,
        "johnAdamsUserScreenNameCell.isDisplayed() = " + johnAdamsUserScreenNameCell.isDisplayed());
    assertTrue(
        "The Screen Name Cell of the John Adams user should be displayed on the page as john.adams at this point but it is not.",
        johnAdamsUserScreenNameCell.isDisplayed());
    logger.log(
        Level.INFO,
        "johnAdamsUserLastNameCell.isDisplayed() = " + johnAdamsUserLastNameCell.isDisplayed());
    assertTrue(
        "The Last Name Cell of the John Adams user should be displayed on the page as John at this point but it is not.",
        johnAdamsUserLastNameCell.isDisplayed());
    logger.log(
        Level.INFO,
        "johnAdamsUserLastNameCell.isDisplayed() = " + johnAdamsUserFirstNameCell.isDisplayed());
    assertTrue(
        "The First Name Cell of the John Adams user should be displayed on the page as Adams at this point but it is not.",
        johnAdamsUserFirstNameCell.isDisplayed());
    logger.log(
        Level.INFO,
        "johnAdamsUserEmailAddressCell.isDisplayed() = "
            + johnAdamsUserEmailAddressCell.isDisplayed());
    assertTrue(
        "The Email Address Cell of the John Adams user should be displayed on the page as [email protected] at this point but it is not.",
        johnAdamsUserEmailAddressCell.isDisplayed());

    logger.log(
        Level.INFO,
        "isThere(browser, samuelAdamsUserScreenNameCellXpath) = "
            + isThere(browser, samuelAdamsUserScreenNameCellXpath));
    assertFalse(
        "The row for Samuel Adams should NOT be displayed now becuase of filtering, but it is displayed.",
        isThere(browser, samuelAdamsUserScreenNameCellXpath));

    for (int i = 0; i < "john.adams".length(); i++) {
      screenNameColumnFilter.sendKeys(Keys.BACK_SPACE);
    }

    Thread.sleep(1000);

    logger.log(
        Level.INFO,
        "isThere(browser, samuelAdamsUserScreenNameCellXpath) = "
            + isThere(browser, samuelAdamsUserScreenNameCellXpath));
    assertTrue(
        "The row for Samuel Adams should be displayed now becuase of filtering, but it is not.",
        isThere(browser, samuelAdamsUserScreenNameCellXpath));
  }
  @Test(
      dataProvider = AtlasConstants.INVALID_SEARCH_STRING,
      dataProviderClass = SearchPage.class,
      priority = 10)
  public void invalidSearchResult(String invalidQuery) {
    LOGGER.info("STARTED: Test verifySearchResultNegative");
    searchPage.searchQuery(invalidQuery);
    // atlasDriver utility function - >customWait(10);

    AtlasDriverUtility.waitUntilElementVisible(
        searchPage.searchPageElements.noResultFound, 50); // Waiting for
    // "no result found"
    // notification
    // to appear
    // on screen

    Assert.assertTrue(
        searchPage.searchPageElements.noResultFound.isDisplayed(), "An Alert Banner displayed");

    String expectedMessage = "No Result found";
    String actualMessage =
        searchPage
            .searchPageElements
            .noResultFound
            .findElement(By.cssSelector(".ng-binding"))
            .getText();

    Assert.assertEquals(actualMessage, expectedMessage, "No Result found message displayed");
    AtlasDriverUtility.waitUntilElementVisible(searchPage.searchPageElements.noResultFound, 10);
    WebElement close =
        searchPage.searchPageElements.noResultFound.findElement(By.tagName("button"));
    Assert.assertTrue(close.isDisplayed(), "Alert message displayed");
    close.click();
    LOGGER.info("ENDED: Test verifySearchResultNegative");
  }
Пример #11
0
 /**
  * Check for is element present on the page.
  *
  * @return Is element present
  */
 public boolean isPresent(int timeout) {
   WebDriverWait wait = new WebDriverWait(Browser.getInstance().getWebDriver(), timeout);
   try {
     wait.until(
         (ExpectedCondition<Boolean>)
             new ExpectedCondition<Boolean>() {
               public Boolean apply(final WebDriver driver) {
                 try {
                   List<WebElement> list = driver.findElements(locator);
                   for (WebElement el : list) {
                     if (el instanceof WebElement && el.isDisplayed()) return el.isDisplayed();
                   }
                   element = driver.findElement(locator);
                 } catch (Exception e) {
                   return false;
                 }
                 return element.isDisplayed();
               }
             });
   } catch (Exception e) {
     warn(e.getMessage().substring(0, e.getMessage().indexOf("}")));
     return false;
   }
   try {
     browser
         .getWebDriver()
         .manage()
         .timeouts()
         .implicitlyWait(Integer.valueOf(browser.getImplicitlyWait()), TimeUnit.SECONDS);
     return element.isDisplayed();
   } catch (Exception e) {
     warn(e.getMessage().substring(0, e.getMessage().indexOf("waiting")));
   }
   return false;
 }
 /**
  * Returns false in case of NoSuchElementException
  *
  * @param webElement
  * @return
  */
 protected boolean isDisplayedSafe(WebElement webElement) {
   try {
     return webElement.isDisplayed();
   } catch (NoSuchElementException e) {
     return false;
   }
 }
  @Test
  public void should_be_able_to_find_an_element_using_a_jquery_expression() {
    StaticSitePage page = getPage();

    WebElement link = page.getDriver().findElement(ByJQuery.selector("a[title='Click Me']"));
    assertThat(link.isDisplayed(), is(true));
  }
Пример #14
0
  // my method to harvest unique nearby places' names
  public boolean checkNearbyPlacesPresence() {
    Set<String> placesNamesSet = new HashSet<String>();
    List<WebElement> list = new ArrayList<WebElement>();

    list.addAll(
        appiumDriver.findElements(
            By.xpath("//android.widget.TextView[contains(@resource-id, 'txtLocationName')]")));
    for (WebElement item : list) {
      placesNamesSet.add(item.getAttribute("text"));
    }

    int oldSetSize = placesNamesSet.size();
    boolean continueScroll = oldSetSize < 1 ? false : true;

    while (continueScroll) {
      ((AppiumDriver) appiumDriver).swipe(545, 1630, 545, 330, 2000);

      nearbyPlaceName.isDisplayed();
      list.clear();
      list.addAll(
          appiumDriver.findElements(
              By.xpath("//android.widget.TextView[contains(@resource-id, 'txtLocationName')]")));
      for (WebElement item : list) {
        placesNamesSet.add(item.getAttribute("text"));
      }
      continueScroll = placesNamesSet.size() > oldSetSize ? true : false;
      oldSetSize = placesNamesSet.size();
    }
    System.out.println("Set of nearby places:");
    for (String item : placesNamesSet) {
      System.out.println(item);
    }
    System.out.println("Total nearby places: " + placesNamesSet.size());
    return placesNamesSet.size() > 0;
  }
Пример #15
0
  @Test
  public void canAddManyListenersPerThread() {
    LogEventListener listener1 = mock(LogEventListener.class);
    LogEventListener listener2 = mock(LogEventListener.class);
    LogEventListener listener3 = mock(LogEventListener.class);

    SelenideLogger.addListener("simpleReport", listener1);
    SelenideLogger.addListener("softAsserts", listener2);
    SelenideLogger.addListener("userProvided", listener3);

    WebElement webElement = mock(WebElement.class);
    when(webdriver.findElement(By.cssSelector("div"))).thenReturn(webElement);
    when(webElement.isDisplayed()).thenReturn(true);

    $("div").click();

    verifyEvent(listener1);
    verifyEvent(listener2);
    verifyEvent(listener3);

    verifyNoMoreInteractions(listener1, listener2, listener3);

    reset(listener1, listener2, listener3);
    SelenideLogger.removeListener("simpleReport");
    SelenideLogger.removeListener("softAsserts");

    $("div").click();
    verifyEvent(listener3);

    verifyNoMoreInteractions(listener1, listener2, listener3);
  }
  public String addNewProject(String projectName) throws InterruptedException {

    WebElement btnNewProj =
        driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.id("new_project")));

    btnNewProj.click();
    TimeUnit.SECONDS.sleep(2);

    executeJavascript("document.getElementsByClassName('edit_me')[0].click();");
    TimeUnit.SECONDS.sleep(2);

    WebElement txtName = getWebDriver().findElement(By.id("projects_project_title"));
    txtName.click();
    txtName.clear();
    txtName.sendKeys(projectName);

    List<WebElement> saveBtnList =
        getWebDriver().findElements(By.xpath(".//*[@id='projects_project_submit_action']/input"));
    for (WebElement btnSave : saveBtnList) {
      if (btnSave.isDisplayed()) btnSave.click();
    }

    TimeUnit.SECONDS.sleep(1);
    String name = "";
    List<WebElement> txtist = getWebDriver().findElements(By.cssSelector(".element-plain-text"));
    for (WebElement title : txtist) {
      if (title.getText().equals(projectName)) {
        name = title.getText();
        break;
      }
    }
    return name;
  }
  private String addFolderAction(String folderToCreate) throws InterruptedException {

    TimeUnit.SECONDS.sleep(2);

    executeJavascript("document.getElementsByClassName('edit_me')[0].click();");
    TimeUnit.SECONDS.sleep(2);

    WebElement txtName = getWebDriver().findElement(By.id("projects_milestone_title"));
    txtName.click();
    txtName.clear();
    txtName.sendKeys(folderToCreate);

    List<WebElement> saveBtnList =
        getWebDriver().findElements(By.xpath(".//*[@id='projects_milestone_submit_action']/input"));
    for (WebElement btnSave : saveBtnList) {
      if (btnSave.isDisplayed()) btnSave.click();
    }

    TimeUnit.SECONDS.sleep(1);
    String name = "";
    List<WebElement> txtist = getWebDriver().findElements(By.cssSelector(".element-plain-text"));
    for (WebElement title : txtist) {
      if (title.getText().equals(folderToCreate)) {
        name = title.getText();
        break;
      }
    }
    return name;
  }
  @Test
  public void shouldManageMenu() {

    for (WebElement e : findElementsBySelector(escapeClientId("form:menu") + " .ui-button")) {

      WebElement hidden = findElementBySelector(e, "input[type='checkbox']");

      assertTrue("Should not be actived with unchecked", !hasClass(e, "ui-state-active"));
      assertTrue("Hidden value should be valid.", !hidden.isSelected());

      e.click();

      assertTrue("Should be actived by selection.", hasClass(e, "ui-state-active"));
      assertTrue("Hidden value should change.", hidden.isSelected());

      e.click();

      assertTrue("Should remove active state.", !hasClass(e, "ui-state-active"));
      assertTrue("Hidden value should change.", !hidden.isSelected());

      e.click();
    }

    findElementById("form:submit").click();

    waitUntilAjaxRequestCompletes();

    WebElement dialog = findElementById("form:dialog");

    assertTrue("Should display result dialog.", dialog.isDisplayed());

    assertTrue(
        "Should display valid results.",
        findElementsBySelector(dialog, ".ui-datalist-item").size() == 3);
  }
 public boolean isTableVisible() {
   WebElement accountTable = getAccountTable();
   if (accountTable != null) {
     return accountTable.isDisplayed();
   }
   return false;
 }
Пример #20
0
 public boolean isElementNotDisplayed(WebElement element) {
   try {
     return !element.isDisplayed();
   } catch (Exception e) {
     return false;
   }
 }
  public static void executeJavaScriptEvent(
      WebDriver webDriver, String locator, String eventType, String event) {

    WebElement webElement = getWebElement(webDriver, locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver wrappedWebDriver = wrapsDriver.getWrappedDriver();

    JavascriptExecutor javascriptExecutor = (JavascriptExecutor) wrappedWebDriver;

    if (!webElement.isDisplayed()) {
      scrollWebElementIntoView(webDriver, webElement);
    }

    StringBuilder sb = new StringBuilder(6);

    sb.append("var element = arguments[0];");
    sb.append("var event = document.createEvent('");
    sb.append(eventType);
    sb.append("');event.initEvent('");
    sb.append(event);
    sb.append("', true, false);");
    sb.append("element.dispatchEvent(event);");

    javascriptExecutor.executeScript(sb.toString(), webElement);
  }
  @Test
  @Override
  public void shouldVerifyDOM() {

    try {

      WebElement accordion = findElementById("form:accordion");

      List<WebElement> headers =
          findElementsBySelector(accordion, "h3.ui-accordion-header[role='tab']");

      List<WebElement> contents =
          findElementsBySelector(
              accordion,
              "h3.ui-accordion-header[role='tab'] + div.ui-accordion-content[role='tabpanel']");

      assertTrue(
          "Should render valid count of accordion items.",
          headers.size() == 3 && contents.size() == 3);

      for (int i = 0; i < headers.size(); i++) {
        WebElement h = headers.get(i);
        WebElement c = contents.get(i);

        assertTrue("Accordion header should be displayed.", h.isDisplayed());

        accordionItemShouldBe(
            h, c, i == 0 ? EXPANDED : NOT_EXPANDED, ENABLED, i != 0 ? NOT_LOADED : LOADED);
      }

    } catch (NoSuchElementException e) {
      assertTrue("Accordion Dynamic showcase DOM not verified.", false);
    }
  }
  public LoginComponentTestPage(WebDriver _driver) {
    this.driver = _driver;
    PageFactory.initElements(driver, this);

    Assert.assertEquals(true, loginBox.isDisplayed());
    System.out.println("debug: login-box is displayed");
  }
Пример #24
0
 public void verifyErrorMessageRequestedQuantityExplanation(String requestedQuantityExplanation) {
   testWebDriver.waitForElementToAppear(requestedQtyExplanationErrorMessage);
   assertTrue("Error message not displaying", requestedQtyExplanationErrorMessage.isDisplayed());
   assertTrue(
       "Error message saying '" + requestedQuantityExplanation + "' not displaying",
       requestedQtyExplanationErrorMessage.getText().equals(requestedQuantityExplanation));
 }
Пример #25
0
 public void verifyErrorMessageDivStockOnHand(String stockOnHandError) {
   testWebDriver.waitForElementToAppear(stockOnHandQtyErrorMessage);
   assertTrue("Error message not displaying", stockOnHandQtyErrorMessage.isDisplayed());
   assertTrue(
       "Error message saying '" + stockOnHandError + "' not displaying",
       stockOnHandQtyErrorMessage.getText().equals(stockOnHandError));
 }
Пример #26
0
 public void verifyErrorMessageDivTotalConsumedQuantity(String totalConsumedQuantityError) {
   testWebDriver.waitForElementToAppear(totalConsumedQtyErrorMessage);
   assertTrue("Error message not displaying", totalConsumedQtyErrorMessage.isDisplayed());
   assertTrue(
       "Error message saying '" + totalConsumedQuantityError + "' not displaying",
       totalConsumedQtyErrorMessage.getText().equals(totalConsumedQuantityError));
 }
  @Test // Not applicable for Liferay Portal 6.0
  @RunAsClient
  @InSequence(0)
  public void testSetupActivateUser() throws Exception {
    browser.manage().window().maximize();
    signIn(browser);
    (new Actions(browser)).click(dropdownTestSetup);

    if (!controlPanelTestSetup.isDisplayed()) {
      dropdownTestSetup.click();
    }

    controlPanelTestSetup.click();
    waitForElement(browser, usersLinkTestSetupXpath);
    usersLinkTestSetup.click();
    waitForElement(browser, searchAllUsersLinkTestSetupXpath);

    if (!isThere(browser, johnAdamsTestSetupXpath) || !johnAdamsTestSetup.isDisplayed()) {

      searchAllUsersLinkTestSetup.click();
      waitForElement(browser, backLinkTestSetupXpath);

      if (isThere(browser, advancedSearchLinkTestSetupXpath)
          && advancedSearchLinkTestSetup.isDisplayed()) {
        advancedSearchLinkTestSetup.click();
      }

      waitForElement(browser, selectStatusTestSetupXpath);
      selectStatusTestSetup.click();
      (new Actions(browser)).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.TAB).perform();
      Thread.sleep(250);

      if (isThere(browser, johnAdamsTestSetupXpath)) {
        // no-op
      } else {
        selectStatusTestSetup.submit();
        Thread.sleep(250);
      }

      if (isThere(browser, johnAdamsTestSetupXpath)) {
        johnAdamsMenuTestSetup.click();
        activateJohnAdamsTestSetup.click();
      }

      waitForElement(browser, usersLinkTestSetupXpath);
    }
  }
Пример #28
0
 private void verifySuccessDiv() {
   String saveSuccessfullyMessage = "Template saved successfully!";
   assertTrue(
       "'" + saveSuccessfullyMessage + "' div not showing up", saveSuccessMsg.isDisplayed());
   assertTrue(
       "'" + saveSuccessfullyMessage + "' not showing up",
       saveSuccessMsg.getText().equals(saveSuccessfullyMessage));
 }
Пример #29
0
 public void verifyErrorMessageDivFooter() {
   testWebDriver.waitForElementToAppear(errorMessageDiv);
   assertTrue("Error message not displaying", errorMessageDiv.isDisplayed());
   String footerErrorMessage = "There are some errors in the form. Please resolve them.";
   assertTrue(
       "Error message saying '" + footerErrorMessage + "' not displaying",
       errorMessageDiv.getText().equalsIgnoreCase(footerErrorMessage));
 }
  public void verifyParticipantPanelIsCollapsed(int id, int timeToWait) {
    WebElement panel = browser.driver.findElement(By.id("panelBodyCollapse-" + id));

    // Need to wait for the total duration according to the number of collapse/expand intervals
    // between panels before checking final state of the panel
    ThreadHelper.waitFor(timeToWait);
    assertFalse(panel.isDisplayed());
  }