Exemplo n.º 1
0
 /**
  * Wait until element has a 'value' attribute.
  *
  * @param value 'Value' Attribute of Element
  * @param timeoutSec seconds to wait until element has a 'value' attribute
  * @param checkCondition log assert for expected conditions.
  * @return Parent instance
  */
 public ParentPanel waitForValue(
     final String value, final int timeoutSec, final boolean checkCondition) {
   boolean isPresent;
   logAction(this, getParentClassName(), format("waitForValueAttribute[%s]: %s", value, locator));
   long start = System.currentTimeMillis() / 1000;
   WebDriverWait wait =
       (WebDriverWait)
           new WebDriverWait(getDriver(), timeoutSec)
               .ignoring(StaleElementReferenceException.class);
   try {
     isPresent =
         wait.until(ExpectedConditions.textToBePresentInElementValue(avatar.byLocator, value));
   } catch (TimeoutException e) {
     logTechnical(
         format(
             "waitForValueAttribute: [ %s ] during: [ %d ] sec ",
             locator, System.currentTimeMillis() / 1000 - start));
     isPresent = false;
   }
   if (checkCondition) {
     logAssertTrue(
         BUSINESS_LEVEL,
         isPresent,
         format(
             "waitForValueAttribute - '%s' should has a value attribute '%s'", getName(), value),
         takePassedScreenshot);
   }
   return parent;
 }
 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"));
   }
 }
Exemplo n.º 3
0
  public void selectDropDownValue(By locator, String text) {

    WebDriverWait wait = new WebDriverWait(driver, 10);
    webElement = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
    webElement = wait.until(ExpectedConditions.elementToBeClickable(locator));
    new Select(webElement).selectByVisibleText(text);
  }
  public static void fillShippingInformation(List<List<String>> shippingInfo) {
    if (!SeleniumController.Instance.Driver().findElement(By.id("address-list")).isDisplayed()) {
      for (int i = 0; i < shippingInfo.size(); i++) {
        SeleniumController.Instance.Driver()
            .findElement(By.id("addressFields"))
            .findElement(By.className(shippingInfo.get(i).get(0)))
            .sendKeys(shippingInfo.get(i).get(1));
        if (shippingInfo.get(i).get(0).equals("country")) {
          SeleniumController.Instance.Driver()
              .findElement(By.id("addressFields"))
              .findElement(By.className(shippingInfo.get(i).get(0)))
              .sendKeys(Keys.ENTER);
          if (shippingInfo.get(i).get(1).contains("United States")) {
            wait.until(
                ExpectedConditions.textToBePresentInElement(
                    SeleniumController.Instance.Driver()
                        .findElement(By.className("shipMethods"))
                        .findElement(By.id("shipMethods")),
                    "U.S."));

          } else
            wait.until(
                ExpectedConditions.textToBePresentInElement(
                    SeleniumController.Instance.Driver()
                        .findElement(By.className("shipMethods"))
                        .findElement(By.id("shipMethods"))
                        .findElement(By.className("shipDescription")),
                    "International"));
        }
      }
    }
  }
Exemplo n.º 5
0
 /**
  * Wait until Expected Condition.
  *
  * @param condition - Expected Condition
  * @param timeoutSec - the maximum time to wait in seconds
  * @param checkCondition log assert for expected conditions.
  * @return Parent instance
  */
 public ParentPanel waitForExpectedConditions(
     final ExpectedCondition<Boolean> condition,
     final int timeoutSec,
     final boolean checkCondition) {
   boolean isTrue;
   logAction(
       this, getParentClassName(), format("waitForExpectedCondition[%s}: %s", condition, locator));
   long start = System.currentTimeMillis() / 1000;
   WebDriverWait wait =
       (WebDriverWait)
           new WebDriverWait(getDriver(), timeoutSec)
               .ignoring(StaleElementReferenceException.class);
   setTimeout(1);
   try {
     wait.until(condition);
     isTrue = false;
   } catch (TimeoutException e) {
     logTechnical(
         format(
             "waitForExpectedCondition: [ %s ] during: [ %d ] sec ",
             locator, System.currentTimeMillis() / 1000 - start));
     isTrue = true;
   }
   setTimeout(TIMEOUT);
   if (checkCondition) {
     logAssertFalse(
         BUSINESS_LEVEL,
         isTrue,
         format("waitForExpectedCondition - '%s'", condition),
         takePassedScreenshot);
   }
   return parent;
 }
 @Test(description = "Verify the staus is 'Unmanaged' after restore complete", priority = 2)
 public void Verify_Status_after_Restore() throws Exception {
   action.driver.navigate().refresh();
   // Click on Inventory,Manage Elements
   action.ClickLink(locator.getProperty("Inventory"));
   action.WaitForTitle(locator.getProperty("Inventory"));
   action.ClickLink(locator.getProperty("Manage_Elements"));
   action.WaitForTitle(locator.getProperty("Manage_Elements"));
   action.VerifyTitle(locator.getProperty("Manage_Elements"));
   action.SwithchFrame("iframe0");
   Thread.sleep(2000);
   action.driver.switchTo().frame("appTableIframe");
   Thread.sleep(2000);
   // Select CM Element
   setup.SelectCMElement(action, input.getProperty("cm29"));
   Thread.sleep(1000);
   WebDriverWait wait = new WebDriverWait(action.driver, 60);
   wait.until(
       ExpectedConditions.elementToBeClickable(By.xpath(locator.getProperty("Currentstatus"))));
   // Click on Get current status button
   action.ClickButton(locator.getProperty("Currentstatus"));
   action.WaitForTitle(locator.getProperty("Manage_Elements"));
   Thread.sleep(90000);
   // Verify the status
   action.VerifyElementValue(locator.getProperty("Mangedby"), "Primary");
   Thread.sleep(2000);
 }
Exemplo n.º 7
0
  public void Test1() {
    WebDriver dr = new FirefoxDriver();
    dr.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);

    try {
      dr.get("http://www.w3schools.com/xsl/xsl_functions.asp");
    } catch (Exception e) {
      // ignore page load time out
      // e.printStackTrace();
    }
    System.out.println(dr.getCurrentUrl());
    WebDriverWait wait = new WebDriverWait(dr, 10);
    wait.until(
        ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//h3[contains(.,'Accessor Functions')]")));
    System.out.println("page loaded");
    WebElement eTable =
        dr.findElement(
            By.xpath("//h3[contains(.,'Accessor Functions')]/following-sibling::table[1]"));

    Table tTable = new Table(eTable);

    System.out.println(tTable.getCellText(1, 1)); // row 1, column 1
    System.out.println(tTable.getCellText("fn,nilled", 1)); // row 2, column 1
    System.out.println(tTable.getCellText(1, "Name")); // row 1, column 1
    System.out.println(tTable.getCellText("fn,nilled", "Description")); // row 2, column 2

    dr.quit();
  }
  @Test
  public void workWithTheIFrame() {
    driver.get("http://www.compendiumdev.co.uk/selenium/frames");
    WebDriverWait wait = new WebDriverWait(driver, Driver.DEFAULT_TIMEOUT_SECONDS);

    assertThat(driver.getTitle(), is("Frameset Example Title (Example 6)"));

    // click on "menu"."iFrames Example"
    driver.switchTo().frame("menu");
    driver.findElement(By.cssSelector("a[href='iframe.html']")).click();

    wait.until(titleIs("HTML Frames Example - iFrame Contents"));

    // click on Example 5 in the iFrame
    driver.switchTo().frame(0);
    driver.findElement(By.cssSelector("a[href='frames_example_5.html']")).click();

    wait.until(titleIs("Frameset Example Title (Example 5)"));

    // then content.load main frames page
    driver.switchTo().frame("content");
    driver.findElement(By.cssSelector("a[href='index.html']")).click();

    wait.until(titleIs("Frameset Example Title (Example 6)"));
  }
Exemplo n.º 9
0
  /**
   * First, verify that window.$A has been installed. Then, wait until {@link
   * #isAuraFrameworkReady()} returns true. We assume the document has finished loading at this
   * point: callers should have previously called {@link #waitForDocumentReady()}.
   */
  public void waitForAuraFrameworkReady(final Set<String> expectedErrors) {
    String doNotAssign =
        "\nThis message means, you aren't even on Aura application at this point. "
            + "Please do not assign this test failure to Aura team/s unless, Aura team/s is the owner of this test. ";
    WebDriverWait waitAuraPresent = new WebDriverWait(driver, timeoutInSecs);
    waitAuraPresent
        .withMessage("Initialization error: Perhaps the initial GET failed." + doNotAssign)
        .until(
            new Function<WebDriver, Boolean>() {
              @Override
              public Boolean apply(WebDriver input) {
                return (Boolean) getRawEval("return !!window.$A");
              }
            });

    WebDriverWait waitFinishedInit = new WebDriverWait(driver, timeoutInSecs);
    waitFinishedInit
        .ignoring(StaleElementReferenceException.class)
        .withMessage("Initialization error: $A present but failed to initialize")
        .until(
            new Function<WebDriver, Boolean>() {
              @Override
              public Boolean apply(WebDriver input) {
                assertNoAuraErrorMessage(expectedErrors);
                return isAuraFrameworkReady();
              }
            });
  }
Exemplo n.º 10
0
 @Override
 public void submit() {
   sumbitButton.click();
   // make sure the fancybox content is not loaded anymore
   WebDriverWait wait = new WebDriverWait(driver, AbstractTest.LOAD_TIMEOUT_SECONDS);
   wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("fancybox-content")));
 }
  @Test
  public void test() {
    // find a wish list
    wd.get(baseURL);
    wd.findElementByXPath(".//*[@id='term']").sendKeys("*****@*****.**");
    wd.findElementByXPath(".//*[@id='wish_list']/div[3]/div/form/fieldset[2]/input").click();

    wd.findElementByXPath(("//input[starts-with(@id,'safe_place_for_courier')]"))
        .sendKeys("home"); // use when there are dynamic elements on the page
    wd.findElementByXPath("//*[@id='add_to_cart']").click();

    WebElement checkoutmodal =
        wait.until(
            ExpectedConditions.visibilityOfElementLocated(
                By.xpath("//*[@id='shopping_buttons']/a[2]")));
    checkoutmodal.click();

    // proceed to checkout
    wd.findElementByXPath(".//*[@id='edit_cart']/section[2]/div/div[2]/span/button").click();

    // welcome page
    WebElement signinemail = wd.findElementByXPath("//*[@id='email']");
    if (signinemail.isEnabled()) signinemail.sendKeys("*****@*****.**");

    WebElement signinpassword = wd.findElementByXPath("//*[@id='password']");
    if (signinpassword.isEnabled()) signinpassword.sendKeys("logmein1");
    wd.findElementById("button_existing_customer").click();

    // Delivery
    wd.findElementById("button_continue").click();

    // Payment flow choice (QA only)
    wd.findElementByXPath(".//*[@id='content']/form/input").click();

    // Payment page
    wd.findElementByXPath(".//*[@id='payment_medium_payment_form_credit_card']").click();

    // Payment form

    wait.until(
        ExpectedConditions.visibilityOfElementLocated(
            By.id("checkout_credit_card_attributes_type")));
    new Select(wd.findElementById("checkout_credit_card_attributes_type"))
        .selectByVisibleText("Visa Debit or Electron");

    wd.findElementById("checkout_credit_card_attributes_number").sendKeys("4263971921001307");
    wd.findElementById("checkout_credit_card_attributes_name").sendKeys("Hans Peter Luhn");
    new Select(wd.findElementById("checkout_credit_card_attributes_expiry_month"))
        .selectByVisibleText("6");
    new Select(wd.findElementById("checkout_credit_card_attributes_expiry_year"))
        .selectByVisibleText("2018");
    wd.findElementById("checkout_credit_card_attributes_verification_value").sendKeys("737");

    // Skip 3DS
    wd.findElementById("checkout_skip_3d_secure").click();

    wd.findElementByXPath("//*[@id='process_payment_button']").click();

    wd.close();
  }
Exemplo n.º 12
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;
 }
  public Page login(String userName, String password, LoginTo loginTo)
      throws IOException, InterruptedException {
    log.info("login as " + userName);

    // Wait until login page loading is completed.
    WebDriverWait wait = new WebDriverWait(driver, 30);

    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("username")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("password")));

    wait.until(
        ExpectedConditions.visibilityOfElementLocated(
            new ByAll(By.className("btn-primary"), By.tagName("input"))));

    driver.findElement(By.id("username")).sendKeys(userName);
    driver.findElement(By.id("password")).sendKeys(password);

    driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);

    driver.findElement(By.className("btn-primary")).click();

    if (loginTo == LoginTo.PUBLISHER) {
      return PublisherWebAppsListPage.getPage(driver, appMServer);
    } else {
      return StoreHomePage.getPage(driver, appMServer);
    }
  }
Exemplo n.º 14
0
  @Test(timeOut = 20000)
  public void SearchingResultPosts() {
    // Validating Search No Results
    HomePage homePage = PageFactory.initElements(driver, HomePage.class);
    homePage.go(driver);
    homePage.search("not found");
    Assert.assertTrue(
        driver.findElement(By.xpath("//article[@id='post-0']/header/h1")).isDisplayed(),
        "Nothing Found");
    Assert.assertEquals("not found | Search Results | Automation Training", driver.getTitle());

    // Validating post results with the word "test"
    homePage.go(driver);
    homePage.waitForTitle();
    homePage.search("test");

    WebDriverWait waitForOne = new WebDriverWait(driver, 10);
    waitForOne.until(
        ExpectedConditions.presenceOfElementLocated(By.xpath("//h1[@id='site-title']/span/a")));
    waitForOne.until(
        ExpectedConditions.presenceOfElementLocated(
            By.xpath("//article[@id='post-39']/header/h1/a")));
    waitForOne.until(
        ExpectedConditions.presenceOfElementLocated(By.linkText("What software testing is")));

    driver.findElement(By.className("page-title")).isDisplayed();

    Assert.assertTrue(
        driver.findElement(By.xpath("//header/h1/span")).isDisplayed(), "SEARCH RESULTS FOR: TEST");

    waitForOne.until(ExpectedConditions.titleContains("test"));

    assert (driver.getTitle().contains(("test | Search Results | Automation Training")));
  }
Exemplo n.º 15
0
  /**
   * Waits until the specified JavaScript returns a non-false value.
   *
   * @param expression the JavaScript expression to evaluate
   * @param timeout time in seconds to wait until a TimeoutException is thrown
   * @throws TimeoutException
   */
  public void evaluatedJavaScriptExpression(String expression, int timeout)
      throws TimeoutException {
    WebDriverWait wait = new WebDriverWait(browser.getWebDriver(), timeout);

    // start waiting for adequate evaluation of expression
    wait.until(new JavaScriptEvaluatedWaitCondition(browser, expression));
  }
Exemplo n.º 16
0
  @Test(expected = NoSuchElementException.class)
  public void shouldBeAbleToClickInAFrame() throws InterruptedException {
    WebDriver d = getDriver();

    d.get("http://docs.wpm.neustar.biz/testscript-api/index.html");
    assertEquals("__MAIN_FRAME__", getCurrentFrameName(d));

    d.switchTo().frame("classFrame");
    assertEquals("classFrame", getCurrentFrameName(d));

    // This should cause a reload in the frame "classFrame"
    d.findElement(By.linkText("HttpClient")).click();

    // Wait for new content to load in the frame.
    WebDriverWait wait = new WebDriverWait(d, 10);
    wait.until(ExpectedConditions.titleContains("HttpClient"));

    // Frame should still be "classFrame"
    assertEquals("classFrame", getCurrentFrameName(d));

    // Check if a link "clearCookies()" is there where expected
    assertEquals("clearCookies", d.findElement(By.linkText("clearCookies")).getText());

    // Make sure it was really frame "classFrame" which was replaced:
    // 1. move to the other frame "packageFrame"
    d.switchTo().defaultContent().switchTo().frame("packageFrame");
    assertEquals("packageFrame", getCurrentFrameName(d));
    // 2. the link "clearCookies()" shouldn't be there anymore
    d.findElement(By.linkText("clearCookies"));
  }
Exemplo n.º 17
0
  /**
   * Wait for the List<WebElement> to be present in the DOM, regardless of being displayed or not.
   * Returns all elements within the current page DOM.
   *
   * @param WebDriver The driver object to be used
   * @param By selector to find the element
   * @param int The time in seconds to wait until returning a failure
   * @return List<WebElement> all elements within the current page DOM, or null (if the timeout is
   *     reached)
   */
  public static List<WebElement> waitForListElementsPresent(
      WebDriver driver, final By by, int timeOutInSeconds) {
    List<WebElement> elements;
    try {
      driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); // nullify implicitlyWait()

      WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
      wait.until(
          (new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(WebDriver driverObject) {
              return areElementsPresent(driverObject, by);
            }
          }));

      elements = driver.findElements(by);
      driver
          .manage()
          .timeouts()
          .implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); // reset implicitlyWait
      return elements; // return the element
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
 @Step("Log out")
 public void logOut() {
   wait.until(ExpectedConditions.elementToBeClickable(productPage.logoutButton));
   productPage.logoutButton.click();
   wait.until(ExpectedConditions.visibilityOf(authPage.email));
   makeScreenshot("The user should be logged out");
 }
Exemplo n.º 19
0
 /**
  * Wait until element is displayed.
  *
  * @param timeoutSec seconds to wait until element is displayed.
  * @param checkCondition log assert for expected conditions.
  * @return Parent instance
  */
 private ParentPanel waitForDisplayed(int timeoutSec, boolean checkCondition) {
   boolean isDisplayed;
   logAction(this, getParentClassName(), format("waitForDisplayed: %s", locator));
   long start = System.currentTimeMillis() / 1000;
   WebDriverWait wait =
       (WebDriverWait)
           new WebDriverWait(getDriver(), timeoutSec)
               .ignoring(StaleElementReferenceException.class);
   setTimeout(1);
   try {
     wait.until(ExpectedConditions.visibilityOfElementLocated(avatar.byLocator));
     isDisplayed = true;
   } catch (TimeoutException e) {
     logTechnical(
         format(
             "waitForDisplayed: [ %s ] during: [ %d ] sec ",
             locator, System.currentTimeMillis() / 1000 - start));
     isDisplayed = false;
   }
   setTimeout(TIMEOUT);
   if (checkCondition) {
     logAssertTrue(
         BUSINESS_LEVEL,
         isDisplayed,
         format("waitForDisplayed - '%s' should be displayed", getName()),
         takePassedScreenshot);
   }
   return parent;
 }
Exemplo n.º 20
0
  @Test
  public void testLogin() {
    driver.get(appUrl + "/#/login");

    WebDriverWait wait = new WebDriverWait(driver, 10);

    WebElement user =
        wait.until(
            ExpectedConditions.presenceOfElementLocated(By.cssSelector("input[type=\"text\"]")));
    user.sendKeys("demo");

    WebElement password =
        wait.until(
            ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("input[type=\"password\"]")));
    password.sendKeys("demo");

    WebElement submit =
        wait.until(
            ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[type=\"submit\"]")));
    submit.submit();

    boolean found =
        wait.until(
            ExpectedConditions.textToBePresentInElement(By.cssSelector("td"), "Assign Approver"));
  }
 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));
   }
 }
Exemplo n.º 22
0
 /**
  * Wait until element is changed text.
  *
  * @param text before change
  * @param timeoutSec seconds to wait until element is changed text
  * @param checkCondition log assert for expected conditions.
  * @return Parent instance
  */
 public ParentPanel waitForTextChanged(
     final String text, final int timeoutSec, final boolean checkCondition) {
   boolean isChanged;
   logAction(this, getParentClassName(), format("waitForTextChanged[%s]: %s", text, locator));
   long start = System.currentTimeMillis() / 1000;
   WebDriverWait wait =
       (WebDriverWait)
           new WebDriverWait(getDriver(), timeoutSec)
               .ignoring(StaleElementReferenceException.class);
   try {
     isChanged =
         wait.until(
             ExpectedConditions.not(
                 ExpectedConditions.textToBePresentInElementLocated(avatar.byLocator, text)));
   } catch (TimeoutException e) {
     logTechnical(
         format(
             "waitForTextChanged: [ %s ] during: [ %d ] sec ",
             locator, System.currentTimeMillis() / 1000 - start));
     isChanged = false;
   }
   if (checkCondition) {
     logAssertTrue(
         BUSINESS_LEVEL,
         isChanged,
         format("waitForTextChanged - '%s' text '%s' should be changed", getName(), text),
         takePassedScreenshot);
   }
   return parent;
 }
  /** Find Element By ID */
  public void findElementById(String objectLocators) {

    WebDriverWait wait = new WebDriverWait(WebDriverClass.getDriver(), 30);
    List<WebElement> list1 =
        wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(objectLocators)));

    listOfElements = list1;
  }
Exemplo n.º 24
0
 /**
  * Waits for element with matching locator to appear in dom.
  *
  * <p>This will wait for at least one element with the locator to appear in the dom, and it will
  * return the first element found. If there are more than one element that match the locator, this
  * will succeed when the first one appears.
  *
  * @param msg Error message on timeout.
  * @param locator By of element waiting for.
  */
 public WebElement waitForElement(String msg, By locator) {
   WaitAndRetrieve war = new WaitAndRetrieve(locator);
   WebDriverWait wait = new WebDriverWait(driver, timeoutInSecs);
   wait.withMessage(msg);
   wait.ignoring(NoSuchElementException.class);
   wait.until(war);
   return war.getFound();
 }
  /** Click on button/checkbox/radio button */
  public void click(MethodParameters model) {

    WebDriverWait wait = new WebDriverWait(WebDriverClass.getDriver(), 30);
    wait.until(ExpectedConditions.elementToBeClickable(model.getElement().get(0))).click();

    MainTestNG.LOGGER.info("click method started" + model.getObjectLocators());
    MainTestNG.LOGGER.info("click method completed");
  }
 public void cancelAmendOrderFromDashboard() {
   wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(cancelAmend)));
   driver.findElement(cancelAmend).click();
   wait.until(
       ExpectedConditions.elementToBeClickable(
           driver.findElement(By.name("Do you want to cancel changes to this order?"))));
   driver.switchTo().alert().accept(); /*Accept the alert message*/
 }
Exemplo n.º 27
0
 @BeforeTest
 public void init() {
   driver = new FirefoxDriver();
   driver.manage().window().maximize();
   driver.get("https://www.redbus.in/");
   WebDriverWait wait = new WebDriverWait(driver, 30);
   wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("Search"))));
 }
 public void searchRequestByID(String expectedID) {
   getDriver().navigate().refresh();
   resetFilterBtn.click();
   WebDriverWait wait = new WebDriverWait(getDriver(), 60);
   wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("loading-mask")));
   messageField.type(expectedID);
   messageField.sendKeys(Keys.ENTER);
 }
Exemplo n.º 29
0
 private static void switchToFrame(WebDriver driver, By byFrameLocator) {
   int timeout = Constants.ELEMENT_TIMEOUT;
   if (driver instanceof OrasiDriver) {
     timeout = ((OrasiDriver) driver).getElementTimeout();
   }
   WebDriverWait wait = new WebDriverWait(driver, timeout);
   wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(byFrameLocator));
 }
Exemplo n.º 30
0
 public boolean isElementClickable(String sLocator) {
   WebDriverWait wait = new WebDriverWait(this, 5);
   try {
     wait.until(ExpectedConditions.elementToBeClickable(By.xpath(sLocator)));
   } catch (TimeoutException exc) {
     return false;
   }
   return true;
 }