@JavascriptEnabled
  @Ignore(
      value = {SAFARI, MARIONETTE},
      issues = {4136})
  @Test
  public void testHoverPersists() throws Exception {
    driver.get(pages.javascriptPage);
    // Move to a different element to make sure the mouse is not over the
    // element with id 'item1' (from a previous test).
    new Actions(driver).moveToElement(driver.findElement(By.id("dynamo"))).build().perform();

    WebElement element = driver.findElement(By.id("menu1"));

    final WebElement item = driver.findElement(By.id("item1"));
    assertEquals("", item.getText());

    ((JavascriptExecutor) driver).executeScript("arguments[0].style.background = 'green'", element);
    new Actions(driver).moveToElement(element).build().perform();

    // Intentionally wait to make sure hover persists.
    Thread.sleep(2000);

    wait.until(not(elementTextToEqual(item, "")));

    assertEquals("Item 1", item.getText());
  }
 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));
 }
  @Override
  public String getFirstNumber(String locator) {
    WebElement webElement = getWebElement(locator);

    String text = webElement.getText();

    if (text == null) {
      return StringPool.BLANK;
    }

    StringBundler sb = new StringBundler();

    char[] chars = text.toCharArray();

    for (char c : chars) {
      boolean digit = false;

      if (Validator.isDigit(c)) {
        sb.append(c);

        digit = true;
      }

      String s = sb.toString();

      if (Validator.isNotNull(s) && !digit) {
        return s;
      }
    }

    return sb.toString();
  }
Beispiel #4
0
  public String checkAddedQTY() {

    while (miniCartQTY1.getSize() == null) allPage.sendKeys(Keys.F5);
    // element appear after text READY is presented

    return (miniCartQTY.getText());
  }
  public MainPage confirmDeleteProject(String projectName) {

    deleteConfirmButton.click();
    projectNameInput.sendKeys(projectName);
    submitDeleteButton.click();
    return new MainPage();
  }
 public void verifyCommentRowContent(
     String commentRowIdSuffix, String commentText, String giverName) {
   WebDriverWait wait = new WebDriverWait(browser.driver, 30);
   WebElement commentRow;
   try {
     commentRow =
         wait.until(
             ExpectedConditions.presenceOfElementLocated(
                 By.id("responseCommentRow" + commentRowIdSuffix)));
   } catch (TimeoutException e) {
     fail("Timeout!");
     commentRow = null;
   }
   try {
     wait.until(
         ExpectedConditions.textToBePresentInElement(
             commentRow.findElement(By.id("plainCommentText" + commentRowIdSuffix)), commentText));
   } catch (TimeoutException e) {
     fail("Not expected message");
   }
   try {
     assertTrue(commentRow.findElement(By.className("text-muted")).getText().contains(giverName));
   } catch (AssertionError e) {
     assertTrue(commentRow.findElement(By.className("text-muted")).getText().contains("you"));
   }
 }
  @Test
  public void shouldNotifyUserWhenEmailAddressesAreDifferent() {
    driver.get(URL);
    String title = driver.getTitle();
    assertEquals("Rule Financial Registration Form", title);

    int randomIntNUmberForRegistration = this.generator.nextInt(100000);

    driver.findElement(By.name("firstName")).clear();
    driver.findElement(By.name("firstName")).sendKeys("Marcin");
    driver.findElement(By.name("lastName")).clear();
    driver.findElement(By.name("lastName")).sendKeys("Kowalczyk");

    String email = new String("marcinkowalczyk" + randomIntNUmberForRegistration + "@gmail.com");

    driver.findElement(By.name("email")).clear();
    driver.findElement(By.name("email")).sendKeys(email);
    driver.findElement(By.name("repeatEmail")).clear();
    driver.findElement(By.name("repeatEmail")).sendKeys("wrong" + email);

    WebElement divErrorEmailAdress =
        driver.findElement(By.xpath("html/body/div[2]/div[2]/div/div/div/div[5]/div/div"));
    boolean ariaHidden = Boolean.getBoolean(divErrorEmailAdress.getAttribute("aria-hidden"));
    assertEquals(ariaHidden, 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));
  }
 public EditProfilePage enterName(String name) {
   log.info("Enter name {}", name);
   nameField.clear();
   nameField.sendKeys(name);
   defocus();
   return new EditProfilePage(getDriver());
 }
Beispiel #10
0
 public List<String> getPhases() {
   List<String> result = new ArrayList<String>();
   for (WebElement webElement : phases) {
     result.add(webElement.getText());
   }
   return result;
 }
  // odi.614 Able to generate reports for time range
  public void search() {
    String dmName = "US_AIRWAYS";
    gotoreports(dmName);
    try {
      driver.findElement(By.id("PARAM_START_DATE")).clear();
      Alert alert = driver.switchTo().alert();
      alert.dismiss();
      driver.findElement(By.id("PARAM_START_DATE")).sendKeys("8/11/2013");
      driver.findElement(By.id("PARAM_END_DATE")).clear();
      alert.dismiss();
      driver.findElement(By.id("PARAM_END_DATE")).sendKeys("9/11/2013");
      driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
      new WebDriverWait(driver, 10)
          .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("reportContent"));
      WebElement page =
          new WebDriverWait(driver, 10)
              .until(ExpectedConditions.visibilityOfElementLocated(By.id("CrystalViewer")));
      WebElement rangeStart = page.findElement(By.xpath("//*[contains(text(),'8/11/2013')]"));
      WebElement rangeEnd = page.findElement(By.xpath("//*[contains(text(),'9/11/2013')]"));
      if (rangeStart != null && rangeEnd != null) {
        System.out.println("Report for selected range is showed");
      }
      ReportFile = new WriteXmlFile();
      driver.switchTo().defaultContent();
      ReportFile.addTestCase("ODI6.x-614:CSSR-Search", "ODI6.x-614:CSSR-Search => Pass");

    } catch (Exception e) {
      System.out.print("trace: ");
      e.printStackTrace();
    }
    // driver.quit();
    ReportFile.WriteToFile();
  }
 @JavascriptEnabled
 @Test
 public void testDraggingElementWithMouseMovesItToAnotherList() {
   performDragAndDropWithMouse();
   WebElement dragInto = driver.findElement(By.id("sortable1"));
   assertEquals(6, dragInto.findElements(By.tagName("li")).size());
 }
  private void performDragAndDropWithMouse() {
    driver.get(pages.draggableLists);

    WebElement dragReporter = driver.findElement(By.id("dragging_reports"));

    WebElement toDrag = driver.findElement(By.id("rightitem-3"));
    WebElement dragInto = driver.findElement(By.id("sortable1"));

    Action holdItem = getBuilder(driver).clickAndHold(toDrag).build();

    Action moveToSpecificItem =
        getBuilder(driver).moveToElement(driver.findElement(By.id("leftitem-4"))).build();

    Action moveToOtherList = getBuilder(driver).moveToElement(dragInto).build();

    Action drop = getBuilder(driver).release(dragInto).build();

    assertEquals("Nothing happened.", dragReporter.getText());

    try {
      holdItem.perform();
      moveToSpecificItem.perform();
      moveToOtherList.perform();

      String text = dragReporter.getText();
      assertTrue(text, text.matches("Nothing happened. (?:DragOut *)+"));
    } finally {
      drop.perform();
    }
  }
  @JavascriptEnabled
  @Test
  @Ignore(
      value = {SAFARI, MARIONETTE},
      reason = "Advanced mouse actions only implemented in rendered browsers",
      issues = {4136})
  @NotYetImplemented(HTMLUNIT)
  @NoDriverAfterTest
  public void testCanMoveOverAndOutOfAnElement() {
    driver.get(pages.mouseOverPage);

    WebElement greenbox = driver.findElement(By.id("greenbox"));
    WebElement redbox = driver.findElement(By.id("redbox"));
    Dimension size = redbox.getSize();

    new Actions(driver).moveToElement(greenbox, 1, 1).perform();

    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    new Actions(driver).moveToElement(redbox).perform();
    assertEquals(
        Colors.RED.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    // IE8 (and *only* IE8) requires a move of 2 pixels. All other browsers
    // would be happy with 1.
    new Actions(driver).moveToElement(redbox, size.getWidth() + 2, size.getHeight() + 2).perform();
    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));
  }
  private void initParams() {
    WebElement dateSlot = getDriver().findElement(By.className("v-datecellslot"));
    int dateSlotWidth = dateSlot.getSize().getWidth();
    noOverlapWidth = dateSlotWidth;
    oneOverlapWidth = dateSlotWidth / 2;
    twoOverlapsWidth = dateSlotWidth / 3;

    Comparator<WebElement> startTimeComparator =
        new Comparator<WebElement>() {
          @Override
          public int compare(WebElement e1, WebElement e2) {
            int e1Top = e1.getLocation().getY();
            int e2Top = e2.getLocation().getY();
            return e1Top - e2Top;
          }
        };

    List<WebElement> eventElements =
        getDriver().findElements(By.className("v-calendar-event-content"));
    Collections.sort(eventElements, startTimeComparator);
    firstEvent = eventElements.get(0);
    secondEvent = eventElements.get(1);
    thirdEvent = eventElements.get(2);

    List<WebElement> resizeBottomElements =
        getDriver().findElements(By.className("v-calendar-event-resizebottom"));
    Collections.sort(resizeBottomElements, startTimeComparator);
    firstEventBottomResize = resizeBottomElements.get(0);
    secondEventBottomResize = resizeBottomElements.get(1);
    thirdEventBottomResize = resizeBottomElements.get(2);
  }
 public EditProfilePage enterEmail(String email) {
   log.info("Enter email {}", email);
   emailField.clear();
   emailField.sendKeys(email);
   defocus();
   return new EditProfilePage(getDriver());
 }
 public void addFeedbackResponseComment(String addResponseCommentId, String commentText) {
   WebDriverWait wait = new WebDriverWait(browser.driver, 5);
   WebElement addResponseCommentForm = browser.driver.findElement(By.id(addResponseCommentId));
   WebElement parentContainer = addResponseCommentForm.findElement(By.xpath("../.."));
   WebElement showResponseCommentAddFormButton =
       parentContainer.findElement(By.id("button_add_comment"));
   showResponseCommentAddFormButton.click();
   wait.until(
       ExpectedConditions.elementToBeClickable(
           addResponseCommentForm.findElement(By.tagName("textarea"))));
   fillTextBox(addResponseCommentForm.findElement(By.tagName("textarea")), commentText);
   addResponseCommentForm
       .findElement(By.className("col-sm-offset-5"))
       .findElement(By.tagName("a"))
       .click();
   if (commentText.equals("")) {
     // empty comment: wait until the textarea is clickable again
     wait.until(
         ExpectedConditions.elementToBeClickable(
             addResponseCommentForm.findElement(By.tagName("textarea"))));
   } else {
     // non-empty comment: wait until the add comment form disappears
     waitForElementToDisappear(By.id(addResponseCommentId));
   }
 }
  private void accept(WebDriver driver, String message) {
    StopWatch stopWatch = new Log4JStopWatch();
    stopWatch.start();

    WebElement img = driver.findElement(By.xpath("//img[@alt='Click to sign']"));
    driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
    img.click();

    List<WebElement> signed_imgs = driver.findElements(By.xpath("//img[@alt='Signed']"));
    driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);

    if (signed_imgs.size() != 0) {
      stopWatch.stop("accept", message);
    } else {
      randomDelay();
      stopWatch.start();
      WebElement awsForm = driver.findElement(By.name("awsForm"));

      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      awsForm.submit();

      signed_imgs = driver.findElements(By.xpath("//img[@alt='Signed']"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      stopWatch.stop("accept'", message);
    }
  }
Beispiel #19
0
  public MetricsAreaFragment getMetricsArea(String title) {
    ////// add property
    By selector =
        By.xpath(
            ".//table[contains(@class, '"
                + PropUtils.get("metrics.container.class")
                + "')][.//h3[text()='"
                + title
                + "']]");
    WebElement element = null;
    try {
      element = getContentRoot().findElement(selector);
    } catch (NoSuchElementException exc) {
      return null;
    }
    MetricsAreaFragment area = Graphene.createPageFragment(MetricsAreaFragment.class, element);

    Map<String, String> metricGrid =
        element
            .findElement(By.className(PropUtils.get("metrics.grid.class")))
            .findElements(By.tagName("tr"))
            .stream()
            .collect(
                Collectors.toMap(
                    e ->
                        e.findElement(By.className(PropUtils.get("metrics.grid.nominal.class")))
                            .getText(),
                    e ->
                        e.findElement(By.className(PropUtils.get("metrics.grid.numerical.class")))
                            .getText()));

    area.setMetricGrid(metricGrid);

    return area;
  }
Beispiel #20
0
  // W-1625895: Safari WebDriver bug- cannot right click because interactions API not implemented
  @ExcludeBrowsers({
    BrowserType.IPAD,
    BrowserType.IPHONE,
    BrowserType.SAFARI,
    BrowserType.ANDROID_PHONE,
    BrowserType.ANDROID_TABLET
  })
  public void testBaseMouseClickEventValue() throws Exception {
    open(TEST_CMP);
    WebElement input = findDomElement(By.cssSelector(".keyup2"));
    WebElement outputValue = findDomElement(By.cssSelector(".outputValue"));

    // IE < 9 uses values 1, 2, 4 for left, right, middle click (respectively)
    String expectedVal =
        (BrowserType.IE7.equals(getBrowserType()) || BrowserType.IE8.equals(getBrowserType()))
            ? "1"
            : "0";
    input.click();
    assertEquals("Left click not performed ", expectedVal, outputValue.getText());

    // right click behavior
    Actions actions = new Actions(getDriver());
    actions.contextClick(input).perform();
    assertEquals("Right click not performed ", "2", outputValue.getText());
  }
Beispiel #21
0
  public static List<Image> getPictureElements(
      WebDriver driver, WebElement webElementSet, int componentNo) {
    List<WebElement> elements = new ArrayList<WebElement>();

    for (String selector : imageCssLocators) {
      elements.addAll(
          WebPageHelpers.createWebElementsList(driver, webElementSet, By.cssSelector(selector)));
    }

    // Add to the list if the webElementSet is an image it's self
    if (webElementSet.getTagName().equals("img")) {
      elements.add(0, webElementSet);
    }

    List<Image> Images = new ArrayList<Image>();
    // Iterate elements list to populate imageBeans list ImageBeans

    if (WebPageHelpers.testWebElementListNotEmpty(elements)) {
      for (WebElement element : elements) {
        Image image =
            new Image(
                element.getAttribute("src"),
                element.getAttribute("width"),
                element.getAttribute("height"));
        Images.add(image);
      }
    }

    if (Images.isEmpty()) {
      return null;
    } else {
      return Images;
    }
  }
Beispiel #22
0
 @ExcludeBrowsers({BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET})
 public void testUpdateOnAttribute_UsingStringSource() throws Exception {
   String event = "blur";
   String baseTag =
       "<aura:component  model=\"java://org.auraframework.components.test.java.model.TestJavaModel\"> "
           + "<div id=\"%s\">"
           + event
           + ":"
           + "<ui:inputText aura:id=\"%s\" class=\"%s\" value=\"{!m.string}\" updateOn=\"%s\"/>"
           + "</div>"
           + "<div id=\"output\">"
           + "output: <ui:outputText value=\"{!m.string}\"/>"
           + "</div>"
           + "</aura:component>";
   DefDescriptor<ComponentDef> cmpDesc =
       addSourceAutoCleanup(ComponentDef.class, baseTag.replaceAll("%s", event));
   open(String.format("/%s/%s.cmp", cmpDesc.getNamespace(), cmpDesc.getName()));
   String value = getCurrentModelValue();
   WebElement input = auraUITestingUtil.findElementAndTypeEventNameInIt(event);
   WebElement outputDiv = findDomElement(By.id("output"));
   assertModelValue(value, "Value shouldn't be updated yet.");
   input.click();
   outputDiv.click(); // to simulate tab behavior for touch browsers
   assertModelValue(event); // value should have been updated
 }
 public int getMatrixTableColumnIndex(String colName) {
   List<WebElement> header = element.findElements(xpath(".//tr[1]/td"));
   for (WebElement webElement : header) {
     System.out.println(webElement.getText());
   }
   return getMatrixColumnNumber(colName, header);
 }
Beispiel #24
0
 private boolean isAFormElement(WebElement webElement) {
   if ((webElement == null) || (webElement.getTagName() == null)) {
     return false;
   }
   String tag = webElement.getTagName().toLowerCase();
   return HTML_FORM_TAGS.contains(tag);
 }
 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));
 }
 /** @since 5.9.3 */
 public void removeFromSelection(final String displayedText) {
   if (!multiple) {
     throw new UnsupportedOperationException(
         "The select2 is not multiple, use #removeSelection instead");
   }
   final String submittedValueBefore = getSubmittedValue();
   boolean found = false;
   for (WebElement el : getSelectedValues()) {
     if (el.getText().equals(displayedText)) {
       Locator.waitUntilEnabledAndClick(
           el.findElement(By.xpath("a[@class='select2-search-choice-close']")));
       found = true;
     }
   }
   if (found) {
     Locator.waitUntilGivenFunction(
         new Function<WebDriver, Boolean>() {
           @Override
           public Boolean apply(WebDriver driver) {
             return !submittedValueBefore.equals(getSubmittedValue());
           }
         });
   } else {
     throw new ElementNotFoundException(
         "remove link for select2 '" + displayedText + "' item", "", "");
   }
 }
 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));
 }
 protected String findNewUserRowIndexLocation() {
   WebElement we = driver.findElement(By.xpath(USER_TABLE_BODY_XPATH_LOCATION));
   if (!StringUtils.equals(we.getTagName(), "tbody")) {
     throw new RuntimeException();
   }
   return String.valueOf(we.findElements(By.tagName("tr")).size());
 }
  // set billing address
  public void setBillingAddress(AMPTestData billingaddress) {

    // vehicleType.get().selectByValue(dealerInfo.getDealerInfo_vehicletype());
    String Checkboxonoff = billingaddress.getPaymentInfo_billinsameasprimaryonoff().toLowerCase();
    if (Checkboxonoff == "on") {
      if (!CheckBox_BillingAsPrimary.isSelected()) {
        // Checking the checkbox
        CheckBox_BillingAsPrimary.click();
      }
    } else if (Checkboxonoff == "off") {
      if (CheckBox_BillingAsPrimary.isSelected()) {
        // Unchecking the checkbox
        CheckBox_BillingAsPrimary.click();
        // Entering the Address details
        DropDown_CCPrefix.get().selectByValue(billingaddress.getPaymentInfo_prefix());
        Input_CCFirstName.enterText(billingaddress.getPaymentInfo_firstname());
        Input_CCLastName.enterText(billingaddress.getPaymentInfo_lastname());
        Dropdown_CCCountry.get().selectByValue(billingaddress.getPaymentInfo_country());
        Input_CCAddress1.enterText(billingaddress.getPaymentInfo_address1());
        Input_CCAddress2.enterText(billingaddress.getPaymentInfo_address2());
        Input_CCCity.enterText(billingaddress.getPaymentInfo_city());
        DropDown_CCState.get().selectByValue(billingaddress.getPaymentInfo_state());
        Input_CCZip.enterText(billingaddress.getPaymentInfo_zipcode());
      }
    }
  }
  @JavascriptEnabled
  @Test
  public void testDragAndDrop() throws InterruptedException {
    driver.get(pages.droppableItems);

    long waitEndTime = System.currentTimeMillis() + 15000;

    while (!isElementAvailable(driver, By.id("draggable"))
        && (System.currentTimeMillis() < waitEndTime)) {
      Thread.sleep(200);
    }

    if (!isElementAvailable(driver, By.id("draggable"))) {
      throw new RuntimeException("Could not find draggable element after 15 seconds.");
    }

    WebElement toDrag = driver.findElement(By.id("draggable"));
    WebElement dropInto = driver.findElement(By.id("droppable"));

    Action holdDrag = getBuilder(driver).clickAndHold(toDrag).build();

    Action move = getBuilder(driver).moveToElement(dropInto).build();

    Action drop = getBuilder(driver).release(dropInto).build();

    holdDrag.perform();
    move.perform();
    drop.perform();

    dropInto = driver.findElement(By.id("droppable"));
    String text = dropInto.findElement(By.tagName("p")).getText();

    assertEquals("Dropped!", text);
  }