/**
   * 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 {
    }
  }
  /**
   * 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));
  }
示例#3
0
  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();
  }
 public int quantidadeMinimaColunistas() {
   return getDriver()
       .findElement(By.className("gente-do-globo"))
       .findElement(By.tagName("ul"))
       .findElements(By.tagName("li"))
       .size();
 }
  public boolean exibiuUmLinkNasImagensENosTitulosDasFotogalerias() {
    for (int i = posicaoInicailDaListaDeFotogalerias();
        i < posicaoInicailDaListaDeFotogalerias() + 4;
        i++) {
      /*listaDeFotogalerias().size() trocado por amostragem de 4*/

      if (!listaDeFotogalerias()
          .get(i)
          .findElement(By.tagName("a"))
          .findElement(By.tagName("img"))
          .isDisplayed()) {
        imprimirMensagemDeErro("imagem sem link", i);
        return false;
      }

      if (!listaDeFotogalerias()
          .get(i)
          .findElement(By.tagName("a"))
          .findElement(By.tagName("span"))
          .isDisplayed()) {
        imprimirMensagemDeErro("titulo sem link", i);
        return false;
      }
    }
    return true;
  }
示例#6
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;
  }
示例#7
0
  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");
  }
示例#8
0
 public WebElement getCell(final WebElement calendar) {
   return calendar
       .findElement(By.tagName("tbody"))
       .findElements(By.tagName("tr"))
       .get(1)
       .findElement(By.tagName("td"));
 }
示例#9
0
  public static void main(String[] args) throws InterruptedException {
    WebDriver dr = new ChromeDriver();

    File file = new File("src/form.html");
    String filePath = "file:///" + file.getAbsolutePath();
    System.out.printf("now accesss %s \n", filePath);

    dr.get(filePath);
    Thread.sleep(1000);

    dr.findElement(By.cssSelector("input[type=checkbox]")).click();
    Thread.sleep(1000);

    dr.findElement(By.cssSelector("input[type=radio]")).click();
    Thread.sleep(1000);

    List<WebElement> options =
        dr.findElement(By.tagName("select")).findElements(By.tagName("option"));
    options.get(options.size() - 1).click();
    Thread.sleep(1000);

    dr.findElement(By.cssSelector("input[type=submit]")).click();

    Alert alert = dr.switchTo().alert();
    System.out.println(alert.getText());
    alert.accept();

    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit();
  }
  public void testViewMacronutrientsAsHCP() throws Exception {
    // Login patient 1.
    WebDriver wd = (HtmlUnitDriver) login("9000000071", "pw");
    assertEquals("iTrust - HCP Home", wd.getTitle());

    // Navigate to the Macronutrients page.
    wd.findElement(By.partialLinkText("Patient Macronutrient")).click();
    assertEquals("iTrust - Please Select a Patient", wd.getTitle());
    wd.findElement(By.name("UID_PATIENTID")).sendKeys("342");
    // the button to click should have the text of the MID
    wd.findElement(By.cssSelector("input[value='342']")).submit();

    assertTrue(
        wd.findElement(By.tagName("body"))
            .getText()
            .contains("Hubert Farnsworth's Macronutrient Intake"));

    wd = (HtmlUnitDriver) login("9000000000", "pw");
    assertEquals("iTrust - HCP Home", wd.getTitle());

    // Navigate to the Macronutrients page.
    wd.findElement(By.partialLinkText("Patient Macronutrient")).click();
    assertEquals("iTrust - Please Select a Patient", wd.getTitle());
    wd.findElement(By.name("UID_PATIENTID")).sendKeys("342");
    // the button to click should have the text of the MID
    wd.findElement(By.cssSelector("input[value='342']")).submit();

    assertTrue(
        wd.findElement(By.tagName("body"))
            .getText()
            .contains("You do not have permission to view the Food Diary!"));
  }
示例#11
0
  public void checkBottomAdD() {
    // Seems that sometimes the ad is embedded in iframe, sometime not!
    String adURL = "";

    try {
      // first, check it in iframe 3
      adURL =
          driver
              .findElement(By.id("bottomleaderboard"))
              .findElement(By.tagName("a"))
              .getAttribute("href");
    } catch (Exception e) {

    }

    if (adURL.length() < 1) {
      try {
        // first, check it in iframe 3
        adURL =
            driver
                .findElement(By.id("bottomleaderboard"))
                .findElement(By.tagName("iframe"))
                .getAttribute("name");
      } catch (Exception e) {

      }
    }

    if (adURL.length() < 1) {
      driver.switchTo().defaultContent();
      try {
        adURL =
            driver
                .findElement(By.id("bottomleaderboard"))
                .findElement(By.tagName("a"))
                .getAttribute("href");
      } catch (Exception e) {

      }

      if (adURL.length() < 1) {
        driver.switchTo().defaultContent();
        try {
          adURL =
              driver
                  .findElement(By.id("bottomleaderboard"))
                  .findElement(By.tagName("iframe"))
                  .getAttribute("name");
        } catch (Exception e) {

        }
      }
    }

    System.out.println("adURL: " + adURL);

    if (adURL.length() < 4) {
      errors.append("No ad is displayed in the bottom Leader Board.");
    }
  }
 public boolean exibiuUmLinkValidoNoTituloDoBox() {
   return !exibiuBoxUltimasNoticias()
       .findElement(By.tagName("p"))
       .findElement(By.tagName("a"))
       .getAttribute("href")
       .isEmpty();
 }
示例#13
0
  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);
      }
    }
  }
 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));
   }
 }
示例#15
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");
  }
 public boolean getVideoLivestream() {
   return getListaVideo()
       .get(0)
       .findElement(By.tagName("div"))
       .findElement(By.tagName("iframe"))
       .getAttribute("src")
       .contains("livestream");
 }
 @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"));
   }
 }
  @Test
  public void testRender() throws Exception {

    //
    driver.get(getURL().toString());
    assertEquals(RunMode.LIVE, RUN_MODE);
    WebElement elt = driver.findElement(By.id("trigger"));
    URL url = new URL(elt.getAttribute("href"));
    driver.get(url.toString());
    assertEquals("ok", driver.findElement(By.tagName("body")).getText());
    assertFalse(SAME_CL_1);
    assertFalse(SAME_CL_2);
    assertNull(SAME_CL_3);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    assertEquals(getErrorStatus(), conn.getResponseCode());
    driver.get(url.toString());
    assertEquals(
        "java.lang.RuntimeException: throwed",
        driver.findElement(By.cssSelector("div.juzu > section > p")).getText().trim());

    // Make a change
    JavaFile pkgFile = getCompiler().assertJavaSource("bridge.runmode.live.controller.A");
    pkgFile.assertSave(pkgFile.assertContent().replace("\"ok\"", "\"OK\""));
    driver.get(applicationURL().toString());
    elt = driver.findElement(By.id("trigger"));
    elt.click();
    assertEquals("OK", driver.findElement(By.tagName("body")).getText());
    assertTrue(SAME_CL_1);
    assertFalse(SAME_CL_2);
    assertNull(SAME_CL_3);

    // Now make fail with compilation error
    pkgFile.assertSave(pkgFile.assertContent().replace("public", "_public_"));

    //
    conn = (HttpURLConnection) applicationURL().openConnection();
    assertEquals(getErrorStatus(), conn.getResponseCode());
    driver.get(applicationURL().toString());
    assertNotNull(driver.findElement(By.cssSelector("div.juzu")));
    assertNotNull(elt);

    //
    pkgFile.assertSave(pkgFile.assertContent().replace("_public_", "public"));

    //
    driver.get(applicationURL().toString());
    elt = driver.findElement(By.id("trigger"));
    elt.click();
    assertEquals("OK", driver.findElement(By.tagName("body")).getText());

    // Add a new class
    JavaFile abc = getCompiler().assertAddJavaSource("bridge.runmode.live.controller.C");
    driver.get(applicationURL().toString());
    assertTrue(SAME_CL_1);
    assertFalse(SAME_CL_2);
    assertTrue(SAME_CL_3);
  }
 @When("I chose to edit the user")
 public void editUser() {
   // TODO currently the user to edit is hard coded to the first row of the users search result.
   // Need to change this.
   WebElement openmrsSearchTable = driver.findElement(By.className("openmrsSearchTable"));
   List<WebElement> trList = openmrsSearchTable.findElements(By.tagName("tr"));
   if (trList.size() > 0)
     trList.get(1).findElement(By.tagName("td")).findElement(By.tagName("a")).click();
 }
  public Map<String, AppEntry> getApplications() {
    Map<String, AppEntry> table = new HashMap<String, AppEntry>();
    for (WebElement r : driver.findElements(By.tagName("tr"))) {
      int count = 0;
      AppEntry currentEntry = null;

      for (WebElement col : r.findElements(By.tagName("td"))) {
        count++;
        switch (count) {
          case 1:
            currentEntry = new AppEntry();
            String client = col.getText();
            table.put(client, currentEntry);
            break;
          case 2:
            String rolesStr = col.getText();
            String[] roles = rolesStr.split(",");
            for (String role : roles) {
              role = role.trim();
              currentEntry.addAvailableRole(role);
            }
            break;
          case 3:
            rolesStr = col.getText();
            if (rolesStr.isEmpty()) break;
            roles = rolesStr.split(",");
            for (String role : roles) {
              role = role.trim();
              currentEntry.addGrantedRole(role);
            }
            break;
          case 4:
            String protMappersStr = col.getText();
            if (protMappersStr.isEmpty()) break;
            String[] protMappers = protMappersStr.split(",");
            for (String protMapper : protMappers) {
              protMapper = protMapper.trim();
              currentEntry.addMapper(protMapper);
            }
            break;
          case 5:
            String additionalGrant = col.getText();
            if (additionalGrant.isEmpty()) break;
            String[] grants = additionalGrant.split(",");
            for (String grant : grants) {
              grant = grant.trim();
              currentEntry.addAdditionalGrant(grant);
            }
            break;
        }
      }
    }
    table.remove("Application");
    return table;
  }
示例#21
0
  /**
   * // * @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());
  }
 public boolean getBoxListaComentario15() throws InterruptedException {
   // getDriver().findElement(By.cssSelector("body > div:nth-child(3) > article > div:nth-child(3)
   // > div:nth-child(1) > div > div.comentarios > div.lista-comentarios > p > a")).click();
   Thread.sleep(1000);
   List<WebElement> novoResultado =
       getDriver()
           .findElement(By.className("lista-comentarios"))
           .findElement(By.tagName("ul"))
           .findElements(By.tagName("li"));
   return novoResultado.size() == 15;
 }
 public SpecialtyCredentialListing(WebElement row) {
   id = Long.valueOf(WebElementUtils.getId(row));
   List<WebElement> cells = getCells(row);
   certifyingBoard = cells.get(CERTIFYING_BOARD_COLUMN).getText();
   specialty = cells.get(SPECIALTY_COLUMN).getText();
   issuer = cells.get(ISSUER_COLUMN).getText();
   startDate = cells.get(START_DATE_COLUMN).getText();
   endDate = cells.get(END_DATE_COLUMN).getText();
   editLink = cells.get(EDIT_COLUMN).findElement(By.tagName("img"));
   deleteLink = cells.get(DELETE_COLUMN).findElement(By.tagName("img"));
 }
 /**
  * @param driver
  * @param frame
  * @return Frame Element
  *     <pre>{@code
  * Get all <frame> tag elements based on the attribute 'name'from
  * the driver and the current URL on driver
  *
  * }</pre>
  */
 protected WebElement getFrameElement(WebDriver driver, String frame) {
   waitForPageLaod(driver, By.tagName("frame"));
   List<WebElement> elementsList = driver.findElements(By.tagName("frame"));
   WebElement frameElement = null;
   for (WebElement webElement : elementsList) {
     if (webElement.getAttribute("name").equals(frame)) {
       frameElement = webElement;
     }
   }
   return frameElement;
 }
  public List<TripDurations> getItineraryTripDurations(HtmlElement itineraryRow, int shipIndex) {
    logger.info("Returning a list of itinerary trip durations for ship index < {} >", shipIndex);
    List<HtmlElement> tds = itineraryRow.findElements(By.tagName("td"));
    List<TripDurations> durations = Lists.newArrayList();
    HtmlElement td = tds.get(shipIndex);
    List<HtmlElement> anchors = td.findElements(By.tagName("a"));
    for (HtmlElement anchor : anchors) {
      durations.add(TripDurations.valueByHRef(anchor.getAttribute("href")));
    }

    return durations;
  }
  public List<DeparturePorts> getItineraryDepartures(HtmlElement itineraryRow, int shipIndex) {
    logger.info("Returning a list of itinerary departure ports for ship index < {} >", shipIndex);
    List<HtmlElement> tds = itineraryRow.findElements(By.tagName("td"));
    List<DeparturePorts> departures = Lists.newArrayList();
    HtmlElement td = tds.get(shipIndex);
    List<HtmlElement> anchors = td.findElements(By.tagName("a"));
    for (HtmlElement anchor : anchors) {
      departures.add(DeparturePorts.valueByHRef(anchor.getAttribute("href")));
    }

    return departures;
  }
 /**
  * @param driver
  * @param span
  * @return Span Element
  *     <pre>{@code
  * Get all <span> tag elements from the driver based on the text and
  * the current URL on driver
  *
  * }</pre>
  */
 protected WebElement getSpanElement(WebDriver driver, String span) {
   waitForPageLaod(driver, By.tagName("span"));
   List<WebElement> elementsList = driver.findElements(By.tagName("span"));
   WebElement frameElement = null;
   for (WebElement webElement : elementsList) {
     if (webElement.getText().contains(span)) {
       frameElement = webElement;
       break;
     }
   }
   return frameElement;
 }
 /**
  * @param driver
  * @param button
  * @return Button Element
  *     <pre>{@code
  * Get all <button> tag elements from the driver based on the
  * attribute 'data-operation' and the current URL on driver
  *
  * }</pre>
  */
 protected WebElement getButtonElement(WebDriver driver, String button, String attr) {
   waitForPageLaod(driver, By.tagName("button"));
   List<WebElement> elementsList = driver.findElements(By.tagName("button"));
   WebElement frameElement = null;
   for (WebElement webElement : elementsList) {
     if (webElement.getAttribute(attr).contains(button)) {
       frameElement = webElement;
       break;
     }
   }
   return frameElement;
 }
 /**
  * @param driver
  * @param src
  * @return Image Element
  *     <pre>{@code
  * Get all <img> tag elements from the driver based on the attribute
  * 'alt' and the current URL on driver
  *
  * }</pre>
  */
 protected WebElement getImgElement(WebDriver driver, String src) {
   waitForPageLaod(driver, By.tagName("img"));
   List<WebElement> elementsList = driver.findElements(By.tagName("img"));
   WebElement frameElement = null;
   for (WebElement webElement : elementsList) {
     if (webElement.getAttribute("alt").contains(src)) {
       frameElement = webElement;
       break;
     }
   }
   return frameElement;
 }
 @Test
 public void webtableTest() {
   WebElement table =
       driver.findElement(By.xpath("html/body/div[1]/div[7]/section[2]/div[1]/table"));
   List<WebElement> rows = table.findElements(By.tagName("tr"));
   for (int i = 0; i < rows.size(); i++) {
     List<WebElement> cols = rows.get(i).findElements(By.tagName("td"));
     for (int j = 0; j < cols.size(); j++) {
       System.out.print(cols.get(j).getText() + "   ");
     }
     System.out.println();
   }
 }