コード例 #1
2
  /**
   * Fills an autocomplete field with a given value.
   *
   * @param driver The WebDriver instance we are working with
   * @param value The new value, or null to generate a non-empty value
   * @param autocompleteInputElement The WebElement into which we are inputting the value
   */
  public static void fillAutocompleteField(
      WebDriver driver, WebElement autocompleteInputElement, String value) {

    if (autocompleteInputElement != null) {
      autocompleteInputElement.click();
      autocompleteInputElement.sendKeys(value);

      new WebDriverWait(driver, 10)
          .until(
              ExpectedConditions.visibilityOfElementLocated(By.className("cs-autocomplete-popup")));

      WebElement popupElement = driver.findElement(By.className("cs-autocomplete-popup"));
      WebElement matchesElement =
          popupElement.findElement(By.className("csc-autocomplete-Matches"));
      WebElement matchSpanElement = null;

      new WebDriverWait(driver, 10)
          .until(
              ExpectedConditions.visibilityOfElementLocated(By.className("cs-autocomplete-popup")));

      for (WebElement candidateMatchElement : matchesElement.findElements(By.tagName("li"))) {
        WebElement candidateMatchSpanElement =
            candidateMatchElement.findElement(By.tagName("span"));

        if (candidateMatchSpanElement.getText().equals(value)) {
          matchSpanElement = candidateMatchSpanElement;
          break;
        }
      }

      if (matchSpanElement != null) {
        // Click the value if found
        new WebDriverWait(driver, 10)
            .until(
                ExpectedConditions.visibilityOfElementLocated(
                    By.className("cs-autocomplete-popup")));

        matchSpanElement.click();

      } else {
        // create a new authority item if one matching it does not already exist
        new WebDriverWait(driver, 10)
            .until(
                ExpectedConditions.visibilityOfElementLocated(
                    By.className("cs-autocomplete-popup")));

        WebElement addToPanelElement =
            popupElement.findElement(By.className("csc-autocomplete-addToPanel"));
        WebElement firstAuthorityItem = addToPanelElement.findElement(By.tagName("li"));

        firstAuthorityItem.click();

        while (findElementsWithTimeout(driver, 0, By.className("cs-autocomplete-popup")).size()
            > 0) {
          // Wait for the popup to close
        }
      }
    } else {
    }
  }
コード例 #2
0
ファイル: Local8Page.java プロジェクト: anahorny/selpotest
  public void testTable() {

    // getting access to the cells of the table
    for (WebElement cell : cells) {
      System.out.println(cell.getText());
    }

    // getting the handler to the rows of the table
    List<WebElement> rows = table.findElements(By.tagName("tr"));
    System.out.println("Table rows count: " + rows.size());

    // print the value of each cell using the rows handler
    int rown;
    int celln;
    rown = 0;
    for (WebElement row : rows) {
      rown++;
      List<WebElement> cells = row.findElements(By.tagName("td"));
      celln = 0;
      for (WebElement cell : cells) {
        celln++;
        System.out.println(
            "Row number: " + rown + ". Cell number: " + celln + ". Value: " + cell.getText());
      }
    }

    // simpler way - all above logics was encapsulated into a tableData function
    System.out.println("Row 2, cell 2: " + tableData(rows)[1][1]);
    assertEquals(tableData(rows)[1][0], "vin");
  }
コード例 #3
0
  /**
   * Find a row in a table where columns exist that contain the specified text. Not all columns of
   * the table need to specified, however the order is important. Finding multiple matching results
   * will result in an error.
   *
   * <p>Once the row has been located, other FindInRow methods can be used that may in turn refer to
   * and set the 'Current Element', this method does not set the current element for that reason.
   *
   * @example FindTableRowWithColumnsThatContainText ["My Name","Where it all began...","December 19
   *     2012"]
   * @section Table
   * @param columnText A comma delimitted list of column values, each column can be double quoted
   */
  @Step("FindTableRowWithColumnsThatContainText \\[(.*)\\]")
  public void findRowInTableWithText(final String columnText) {

    final WebElement currentElement = webDriverContext().getCurrentElement();

    Assert.assertThat(
        "expecting the current element to be a table",
        currentElement.getTagName(),
        equalToIgnoringCase("table"));

    final String[] columnValues = columnText.split(",");
    final List<String> columnValList = new ArrayList<String>();
    for (final String s : columnValues) {
      columnValList.add(s.replaceAll("\"", "").trim());
    }

    final List<WebElement> tableRows = currentElement.findElements(By.tagName("tr"));

    List<WebElement> matchingRows = null;

    // TODO - refactor this into WebDriver Bys ..?

    // go through all rows
    for (final WebElement row : tableRows) {

      // for each row
      final List<WebElement> tableCells = row.findElements(By.tagName("td"));

      int lookingForIdx = 0;

      boolean found = false;
      // do we have a match ?
      for (final WebElement td : tableCells) {

        if (td.getText().contains(columnValList.get(lookingForIdx))) {

          lookingForIdx++;
          if (lookingForIdx >= columnValList.size()) {
            // found em all
            found = true;
            break;
          }
        }
      }

      if (found) {
        if (matchingRows == null) {
          matchingRows = new ArrayList<WebElement>();
        }
        matchingRows.add(row);
      }
    }

    Assert.assertNotNull("Didn't find any rows with values: [" + columnText + "]", matchingRows);

    Assert.assertThat(
        "Found too many rows that match values: [" + columnText + "]", matchingRows.size(), is(1));

    webDriverContext().stashElement(TABLE_ROW_KEY, matchingRows.get(0));
  }
コード例 #4
0
ファイル: dice.java プロジェクト: gouthu/myproject
  public void search() throws Exception {
    String str;
    driver.findElement(By.id("search-field-keyword")).sendKeys("qa jobs");
    driver.findElement(By.id("search-field-location")).clear();
    driver.findElement(By.id("search-field-location")).sendKeys("New York, NY");
    driver.findElement(By.xpath("//*[@class='btn btn-primary btn-lg btn-block']")).click();
    Thread.sleep(5000);
    WebElement w = driver.findElement(By.xpath("//*[@id='search-results-control']/div/div"));
    List<WebElement> lst = w.findElements(By.tagName("a"));
    for (int i = 0; i < lst.size(); i++) {
      WebElement w1 = driver.findElement(By.xpath("//*[@id='search-results-control']/div/div"));
      List<WebElement> lst1 = w1.findElements(By.tagName("a"));

      if (lst1.get(i).getText().startsWith("QA")) {
        driver.findElement(By.linkText(lst1.get(i).getText())).click();
        Thread.sleep(5000);
        str =
            driver
                .findElement(
                    By.xpath(
                        "//*[contains(@id,'jobdescSec') or contains(@class,'job_description')]"))
                .getText();
        System.out.println(str);
        driver.navigate().back();
        Thread.sleep(5000);
      }
    }
  }
コード例 #5
0
 @Test(enabled = true, priority = 4)
 public void ThreemmSolventWeldWasteMuPVCProductPage() throws IOException, InterruptedException {
   File file = new File("C:\\Selenium\\jenkindemo\\src\\objectRepositry\\Products_PageObjects");
   FileInputStream input = new FileInputStream(file);
   Properties prop = new Properties();
   prop.load(input);
   dr.navigate().to(prop.getProperty("PlumbingWasteProductPage"));
   dr.findElement(By.xpath(prop.getProperty("SolventWeldWasteMuPVCProducts"))).click();
   WebElement Subproductname = dr.findElement(By.xpath(prop.getProperty("subproductname")));
   String Subproname = Subproductname.getText();
   System.out.println(
       "***********************************************************************************************");
   System.out.println("\t\tThe Sub Product Name is:" + Subproname);
   dr.findElement(By.xpath(prop.getProperty("32mmSolventWeldWasteMuPVCProducts"))).click();
   WebElement Subcatproductname = dr.findElement(By.xpath(prop.getProperty("subproductname")));
   String Subcatproname = Subcatproductname.getText();
   System.out.println(
       "***********************************************************************************************");
   System.out.println("\t\tThe Sub category Product Name is:" + Subcatproname);
   WebElement SubProduct = dr.findElement(By.xpath(prop.getProperty("subproduct")));
   List<WebElement> list = SubProduct.findElements(By.tagName("div"));
   int t = list.size();
   for (int i = 1; i <= t; i++) {
     String str1 = prop.getProperty("subproduct_part1");
     String str2 = prop.getProperty("subproduct_part2");
     dr.findElement(By.xpath(str1 + i + str2)).click();
     WebElement productname = dr.findElement(By.xpath(prop.getProperty("subcatproductname")));
     String finalcatproname = productname.getText();
     System.out.println(
         "***********************************************************************************************");
     System.out.println("\t\tThe Final Product Name is:" + finalcatproname);
     System.out.println(
         "***********************************************************************************************");
     WebElement FinalSubProduct = dr.findElement(By.xpath(prop.getProperty("FinalProduct")));
     List<WebElement> FinalSubproducts = FinalSubProduct.findElements(By.tagName("figure"));
     int Subtotal = FinalSubproducts.size();
     for (int n = 1; n <= Subtotal; n++) {
       String str5 = prop.getProperty("ProductImage_Part1");
       String str6 = prop.getProperty("ProductImage_Part2");
       String str8 = prop.getProperty("Finalproductname_part1a");
       String str13 = prop.getProperty("popupClose");
       int r = Subtotal + 1;
       JavascriptExecutor jse = (JavascriptExecutor) dr;
       jse.executeScript("scroll(0,-500);");
       TimeUnit.SECONDS.sleep(2);
       WebElement ProductName = dr.findElement(By.xpath(str5 + n + str8));
       String Name = ProductName.getText();
       String Proname = Name.replaceAll("[\r\n]+", " ");
       System.out.println("The Recently viewed product name is:" + Proname);
       dr.findElement(By.xpath(str5 + n + str6)).click();
       dr.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
       // ScreenCapture();
       TimeUnit.SECONDS.sleep(2);
       dr.findElement(By.xpath(str5 + r + str13)).click();
     }
     dr.navigate().to(prop.getProperty("32mmSolventWeldWasteMuPVCProductPage"));
   }
 }
コード例 #6
0
 public List<WebElement> getUpdatedMsgState(MessageType messageType) throws Exception {
   WebElement messagesTable = service.findElement(tableLocator);
   if (messageType.equals(MessageType.AGENT)) {
     return messagesTable.findElements(agentLineLocator);
   } else if (messageType.equals(MessageType.VISITOR)) {
     return messagesTable.findElements(visitorLineLocator);
   }
   return null;
 }
コード例 #7
0
  public List<WebElementFacade> thenFindAll(String xpathOrCssSelector) {
    List<WebElement> nestedElements = Lists.newArrayList();
    if (PageObject.isXPath(xpathOrCssSelector)) {
      nestedElements = webElement.findElements((By.xpath(xpathOrCssSelector)));
    } else {
      nestedElements = webElement.findElements((By.cssSelector(xpathOrCssSelector)));
    }

    return webElementFacadesFrom(nestedElements);
  }
コード例 #8
0
ファイル: MedicineOnMainPage.java プロジェクト: yacov/Genefo
  /**
   * // * @param nameMedicineShort // * @param nameMedicineFull
   *
   * @return
   * @throws IOException
   * @throws InterruptedException
   */
  public void createMedicinePostRandom(String nameOfMed, String reasonOfMed)
      throws InterruptedException {
    setNameOfMedicine(nameOfMed);
    WebElement nameOfMedicine;
    // creating list of proposed Eleemtns
    List<WebElement> nameOfMedicineList = nameOfMedicineOptions.findElements(By.tagName("li"));
    // picking random element
    Random rand = new Random();
    int nameOfMedicineCounter = rand.nextInt(1);
    nameOfMedicine = nameOfMedicineList.get(nameOfMedicineCounter);
    String name = nameOfMedicine.getText();
    Log.info("Choosing randomly name of medicine from list: " + name + " ");
    clickElement(nameOfMedicine);

    setReasonForMedicine(reasonOfMed);
    WebElement reasonForMedicine;
    List<WebElement> reasonForMedicineList =
        reasonForMedicineOptions.findElements(By.tagName("li"));
    Random rand2 = new Random();
    int nameOfReasonCounter = rand2.nextInt(1);
    reasonForMedicine = reasonForMedicineList.get(nameOfReasonCounter);
    String reason = reasonForMedicine.getText();
    Log.info("Choosing randomly name of medicine from list: " + reason + " ");
    clickElement(reasonForMedicine);

    Log.info("Typing text in 'Tell Us More' field: Testing post ");
    typeTellUsMore("Testing post");
    clickOnAllStarsTogether();
    rateFifeStars();
    clickOnPostButton();
    Log.info("Checking, that medicine and medicine reason are posted in a right way");
    name.equalsIgnoreCase(medicineName.getText());
    Log.info(
        "Medicine is posted in a right way: choosen "
            + name
            + ", posted "
            + medicineName.getText());
    Reporter.log(
        "Medicine is posted in a right way: choosen "
            + name
            + ", posted "
            + medicineName.getText());
    reason.equalsIgnoreCase(reasonName.getText());
    // Assert.assertEquals(reasonName.getText(), reason, "Medicine reason name doesen't match");
    Log.info(
        "Medicine reason is posted in a right way: choosen "
            + reason
            + ", posted "
            + reasonName.getText());
    Reporter.log(
        "Medicine is posted in a right way: choosen "
            + reason
            + ", posted "
            + reasonName.getText());
  }
コード例 #9
0
ファイル: EditorPage.java プロジェクト: Halcom/zanata-server
 public List<String> getComparisonTextDiff() {
   log.info("Query diff from history compare");
   List<String> diffs = new ArrayList<>();
   for (WebElement element : getCompareTabEntries()) {
     for (WebElement diffElement : element.findElements(By.className("diff-insert"))) {
       diffs.add("++" + diffElement.getText());
     }
     for (WebElement diffElement : element.findElements(By.className("diff-delete"))) {
       diffs.add("--" + diffElement.getText());
     }
   }
   return diffs;
 }
  @Test
  public void testAbcd() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.linkText("Sign In")).click();

    driver.findElement(By.linkText("Sign In")).getText();
    driver.findElement(By.xpath("//input[@name='loginName']")).clear();
    driver.findElement(By.xpath("//input[@name='loginName']")).sendKeys("*****@*****.**");
    driver.findElement(By.xpath("//input[@name='password']")).clear();
    driver.findElement(By.xpath("//input[@name='password']")).sendKeys("demo123");
    driver.findElement(By.xpath("//input[@type='image']")).click();
    driver.findElement(By.linkText("Money")).click();

    driver.findElement(By.linkText("Portfolio")).click();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    WebElement table = driver.findElement(By.id("table-holding-data"));

    if (table.isDisplayed()) {

      List<WebElement> rows = table.findElements(By.tagName("tr"));

      System.out.println("Row Count - " + rows.size());

      Iterator<WebElement> i = rows.iterator();

      System.out.println("Table has following content");

      while (i.hasNext()) {

        WebElement row = i.next();

        List<WebElement> columns = row.findElements(By.tagName("td"));

        Iterator<WebElement> j = columns.iterator();

        while (j.hasNext()) {

          WebElement column = j.next();

          System.out.print(column.getText());

          System.out.print("    |  ");
        }
        System.out.println("--------------------");
      }
      System.out.println("Table content is printed");
    } else {
      System.out.println("Table not found");
    }
  }
コード例 #11
0
ファイル: WebParser.java プロジェクト: Fizzr/AW-Registration
  public void edit(User user) {

    driver.get("https://www.academicwork.se/my-profile");

    WebElement partTime = driver.findElement(By.id("t1"));
    WebElement fullTime = driver.findElement(By.id("t2"));
    WebElement consultant = driver.findElement(By.id("t3"));
    WebElement recruitment = driver.findElement(By.id("t4"));

    WebElement jobOptionList =
        driver.findElement(
            By.xpath("//form[@id='create-subscription-form']/fieldset/div[3]/div[1]/div[2]/ul"));
    List<WebElement> allJobOptions = jobOptionList.findElements(By.className("filter"));

    if (!user.jobOptions[0]) {
      partTime.click();
    }
    if (!user.jobOptions[1]) {
      fullTime.click();
    }
    if (!user.jobOptions[2]) {
      consultant.click();
    }
    if (!user.jobOptions[3]) {
      recruitment.click();
    }

    int i = 0;
    for (boolean j : user.jobs) {
      if (j) {
        allJobOptions.get(jobs[i]).click();
      }
      i++;
    }

    WebElement locationOptionList =
        driver.findElement(
            By.xpath("//form[@id='create-subscription-form']/fieldset/div[4]/div[1]/div[2]/ul"));
    List<WebElement> allLocationOptions = locationOptionList.findElements(By.className("filter"));

    i = 0;
    for (boolean j : user.locations) {
      if (j) {
        allLocationOptions.get(locations[i]).click();
      }
      i++;
    }
    partTime.submit();
    user.isDone = true;
  }
コード例 #12
0
 public void clickVisibilityOptionForResponseCommentAndSave(
     String idString, int numOfTheCheckbox) {
   String idSuffix = idString.substring(18);
   WebElement commentRow = browser.driver.findElement(By.id(idString));
   commentRow.findElements(By.tagName("a")).get(1).click();
   WebElement commentEditForm =
       browser.driver.findElement(By.id("responseCommentEditForm" + idSuffix));
   commentRow.findElement(By.id("frComment-visibility-options-trigger" + idSuffix)).click();
   commentRow.findElements(By.cssSelector("input[type='checkbox']")).get(numOfTheCheckbox).click();
   commentEditForm
       .findElement(By.className("col-sm-offset-5"))
       .findElement(By.tagName("a"))
       .click();
   ThreadHelper.waitFor(1000);
 }
コード例 #13
0
 public void chooseDateRange(String value) {
   WebElement select = this.findElement(ReportToolbarUI.EXTRACT_DATA_CHOOSE_DATE_RANGE);
   List<WebElement> optgroups = select.findElements(By.tagName("optgroup"));
   for (WebElement optgroup : optgroups) {
     List<WebElement> options = optgroup.findElements(By.tagName("option"));
     for (WebElement option : options) {
       if (option.getText().equals(value)) {
         option.click();
         break;
       }
     }
     break;
   }
   this.sleep(3000);
 }
コード例 #14
0
  @Test
  public void shouldCloseTab() throws InterruptedException {
    WebElement tabView = findElementById("form:tabView");
    List<WebElement> tabs = tabView.findElements(By.tagName("li"));
    tabs.get(1).findElement(By.className("ui-icon-close")).click();

    waitUntilAjaxRequestCompletes();
    List<WebElement> tabContents =
        findElementByClass("ui-tabs-panels").findElements(By.tagName("div"));
    tabs = tabView.findElements(By.tagName("li"));
    assertThat(tabs.size(), equalTo(2));
    assertThat(tabContents.size(), equalTo(2));

    assertThat(tabs.get(0).findElement(By.tagName("a")).getText(), equalTo("Godfather Part I"));
    assertThat(tabs.get(1).findElement(By.tagName("a")).getText(), equalTo("Godfather Part III"));
  }
コード例 #15
0
 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());
 }
コード例 #16
0
 public List<String> getSelectOptions() {
   List<WebElement> results = Collections.emptyList();
   if (webElement != null) {
     results = webElement.findElements(By.tagName("option"));
   }
   return convert(results, new ExtractText());
 }
コード例 #17
0
 private boolean hasNext() {
   WebElement element = cataloguePage.getMainBlock().getNextPage();
   if (!CollectionUtils.isEmpty(element.findElements(By.className(NavigationLine.ACTIVE_LINK)))) {
     return true;
   }
   return false;
 }
コード例 #18
0
  private void next() {

    WebElement element = cataloguePage.getMainBlock().getNextPage();
    if (!CollectionUtils.isEmpty(element.findElements(By.className(NavigationLine.ACTIVE_LINK)))) {
      element.findElement(By.className(NavigationLine.ACTIVE_LINK)).click();
    }
  }
コード例 #19
0
 @JavascriptEnabled
 @Test
 public void testDraggingElementWithMouseMovesItToAnotherList() {
   performDragAndDropWithMouse();
   WebElement dragInto = driver.findElement(By.id("sortable1"));
   assertEquals(6, dragInto.findElements(By.tagName("li")).size());
 }
コード例 #20
0
ファイル: insider.java プロジェクト: asitang/otcmarketsNEWS
  public static void extractnews(String symbol, String path)
      throws InterruptedException, IOException {
    // WebDriver driver = new HtmlUnitDriver();
    WebDriver driver = new FirefoxDriver();

    driver.get("http://www.otcmarkets.com/stock/" + symbol + "/insider-transactions");

    Thread.sleep(3000);

    boolean next = true;
    int count = -1;

    while (next) {
      next = false;
      count++;

      // grab the whole page and the link

      File file = new File(path + driver.getCurrentUrl().replaceAll("/", "_") + '_' + count);
      if (!file.exists()) {
        file.createNewFile();
      }
      FileWriter fw = new FileWriter(file);
      fw.write(driver.getPageSource());
      fw.flush();
      fw.close();

      System.out.println(driver.getCurrentUrl() + '/' + count);
      // System.out.println(driver.getPageSource());

      // check for the next button, if found then click set the flag to true
      WebElement pagination = null;
      try {
        pagination =
            driver.findElement(By.id("shortInterestTable")).findElement(By.className("pageList"));
      } catch (Exception e) {
        continue;
      }
      List<WebElement> paginationli = pagination.findElements(By.tagName("li"));

      for (WebElement ele : paginationli) {

        try {
          ele.findElement(By.tagName("a")).getText();
        } catch (Exception e) {
          continue;
        }

        if (ele.findElement(By.tagName("a")).getText().equals("next >")) {
          // System.out.println("HI");
          WebElement nextpage = ele.findElement(By.tagName("a"));
          nextpage.click();
          next = true;
          Thread.sleep(3000);
        }
      }
    }

    driver.quit();
  }
コード例 #21
0
 public List<String> getPluginKeys() {
   List<String> pluginKeys = new ArrayList<String>();
   for (WebElement e : pluginsTable.findElements(By.tagName("tr"))) {
     pluginKeys.add(e.getAttribute("data-pluginkey"));
   }
   return pluginKeys;
 }
コード例 #22
0
  public static String data() {

    String value = null;

    List<WebElement> rows = tabletrs.findElements(By.tagName("tr"));
    // int rsize=rows.size();
    //	System.out.println("Toatl Number Of Row "+ rsize);

    for (int rnum = 0; rnum < 1; rnum++) {

      List<WebElement> columns =
          rows.get(rnum).findElements(By.xpath("//table[@class='list_viewnew']//td[3]"));
      // int  colsize=columns.size();

      // System.out.println("Number of columns:"+columns.size());

      for (int cnum = 0; cnum < columns.size() - 1; ) {

        value = columns.get(0).getText();
        System.out.println(value + " Going to delete");
        break;
        // System.out.println(cnum + " block is " + columns.get(cnum).getText());
        // System.out.println(columns.get(cnum).getText());

      }
    }
    // System.out.println(colsize);
    return value;
  }
コード例 #23
0
  public void selectTab(String tabName) {
    try {

      int idx = 0;
      boolean found = false;
      List<WebElement> tabs = _jQueryUITab.findElements(By.cssSelector(".ui-tabs-nav > li"));
      for (WebElement tab : tabs) {
        if (tabName.equals(tab.getText().toString())) {

          WrapsDriver wrappedElement = (WrapsDriver) _jQueryUITab;
          JavascriptExecutor driver = (JavascriptExecutor) wrappedElement.getWrappedDriver();

          driver.executeScript(
              "jQuery(arguments[0]).tabs().tabs('select',arguments[1]);", _jQueryUITab, idx);
          found = true;
          break;
        }
        idx++;
      }

      if (found == false) {
        throw new Exception("Could not find tab '" + tabName + "'");
      }
    } catch (Exception e) {
      // TODO: handle exception
    }
  }
コード例 #24
0
 public void fillRemindParticularUsersForm() {
   WebElement remindModal = browser.driver.findElement(By.id("remindModal"));
   List<WebElement> usersToRemind = remindModal.findElements(By.name("usersToRemind"));
   for (WebElement e : usersToRemind) {
     markCheckBoxAsChecked(e);
   }
 }
  @Test
  @Ignore(
      "I would love for this to work consistently but it fails too often between releases to use as an example")
  public void multiSelectWithUserInteractions() {

    WebElement multiSelect;

    multiSelect = driver.findElement(By.cssSelector("select[multiple='multiple']"));
    List<WebElement> multiSelectOptions = multiSelect.findElements(By.tagName("option"));

    // in real life, clicking on a multi select item without holding down
    // CTRL will deselect all others and select only that one item

    Actions actions = new Actions(driver);

    actions
        .click(multiSelectOptions.get(0))
        .click(multiSelectOptions.get(1))
        .click(multiSelectOptions.get(2))
        .perform();

    clickSubmitButton();

    new WebDriverWait(driver, 10).until(ExpectedConditions.titleIs("Processed Form Details"));

    assertEquals(
        "Expected only 1 match",
        1,
        driver.findElements(By.cssSelector("[id^='_valuemultipleselect']")).size());
  }
コード例 #26
0
 public List<WebElement> getExistingTemplatesLinks() {
   WebElement availableTemplatesHeader =
       getDriver().findElement(By.id("HAvailableTemplateProviders"));
   // a bit unreliable here, but it's the best I can do
   WebElement ul = availableTemplatesHeader.findElement(By.xpath("following-sibling::node()"));
   return ul.findElements(By.tagName("a"));
 }
コード例 #27
0
  public boolean deleteWebApp(String webAppContext) throws Exception {
    WebElement table_element = driver.findElement(By.id("webappsTable"));
    List<WebElement> tr_collection =
        table_element.findElement(By.tagName("tbody")).findElements(By.tagName("tr"));
    if (tr_collection.size() == 0) {
      throw new Exception("Web App you are trying to delete not exists");
    }
    List<WebElement> td_collection;
    for (WebElement tr : tr_collection) {
      td_collection = tr.findElements(By.tagName("td"));
      if (webAppContext.equals(td_collection.get(1).getText())) {
        td_collection.get(0).findElement(By.tagName("input")).click();
        driver.findElement(By.id("delete2")).click();
        Assert.assertEquals(
            driver.findElement(By.id("messagebox-confirm")).getText(),
            "Do you want to delete the selected applications?",
            "Delete Confirmation message mismatched");
        List<WebElement> buttons = driver.findElements(By.tagName("button"));
        for (WebElement button : buttons) {
          if ("yes".equalsIgnoreCase(button.getText())) {
            button.click();
            break;
          }
        }

        Assert.assertEquals(
            driver.findElement(By.id("messagebox-info")).getText(),
            "Successfully deleted selected applications",
            "Web Application deletion failed" + ". Message box content mis matched");
        driver.findElement(By.xpath("/html/body/div[3]/div[2]/button")).click();
        return true;
      }
    }
    throw new Exception("Web App you are trying to delete not exists");
  }
コード例 #28
0
  public boolean findWebApp(String webAppContext) {
    WebElement table_element = driver.findElement(By.id("webappsTable"));
    List<WebElement> tr_collection =
        table_element.findElement(By.tagName("tbody")).findElements(By.tagName("tr"));

    log.info("Number of rows in webapp table = " + tr_collection.size());
    if (tr_collection.size() == 0) {
      return false;
    }
    int row_num, col_num;
    row_num = 1;
    for (WebElement trElement : tr_collection) {
      List<WebElement> td_collection = trElement.findElements(By.tagName("td"));
      col_num = 1;
      for (WebElement tdElement : td_collection) {
        log.info("row # " + row_num + ", col # " + col_num + "text=" + tdElement.getText());
        if (tdElement.getText().equals(webAppContext)) {
          log.info("Webapp context found");
          return true;
        }
        col_num++;
      }
      row_num++;
    }
    return false;
  }
コード例 #29
0
 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);
 }
コード例 #30
0
ファイル: PermissionsSubPage.java プロジェクト: nuxeo/nuxeo
 private WebElement findDeleteButton(String permission, String userOrGroupName) {
   List<WebElement> elements =
       driver.findElements(By.xpath("//div[contains(@class, 'acl-table-row effective')]"));
   for (WebElement element : elements) {
     List<WebElement> names = element.findElements(By.xpath(".//span[contains(@class, 'tag')]"));
     List<WebElement> perms = element.findElements(By.className("label"));
     if (names.size() > 0 && perms.size() > 0) {
       String title = names.get(0).getAttribute("title");
       String perm = perms.get(0).getText();
       if (title.startsWith(userOrGroupName) && permission.equalsIgnoreCase(perm)) {
         return element.findElement(By.xpath(".//paper-icon-button[@icon='delete']"));
       }
     }
   }
   return null;
 }