@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");
    }
  }
  @Ignore // Ignored because you need to kickstart Python SimpleHTTPServer before it can run
  @Test
  public void shouldSwitchToTheRightFrame_issue226() {
    // NOTE: before starting this test,
    // run `python -m SimpleHTTPServer` from within `test/testcase-issue_226`.
    // This will launch a minimal webserver to serve the pages for this test.
    WebDriver d = getDriver();

    // Load "outside.html" and check it's the right one
    d.get("http://localhost:8000/outside.html");
    assertTrue(d.getPageSource().contains("Editing testDotAtEndDoesNotDelete"));
    assertEquals(2, d.findElements(By.tagName("iframe")).size());

    // Find the iframe with class "gwt-RichTextArea"
    WebElement iframeRichTextArea = d.findElement(By.className("gwt-RichTextArea"));

    // Switch to the iframe via WebElement and check it's the right one
    d.switchTo().frame(iframeRichTextArea);
    assertEquals(0, d.findElements(By.tagName("title")).size());
    assertFalse(d.getPageSource().contains("Editing testDotAtEndDoesNotDelete"));
    assertEquals(0, d.findElements(By.tagName("iframe")).size());

    // Switch back to the main frame and check it's the right one
    d.switchTo().defaultContent();
    assertEquals(2, d.findElements(By.tagName("iframe")).size());

    // Switch again to the iframe, this time via it's "frame number" (i.e. 0 to n)
    d.switchTo().frame(0);
    assertEquals(0, d.findElements(By.tagName("title")).size());
    assertFalse(d.getPageSource().contains("Editing testDotAtEndDoesNotDelete"));
    assertEquals(0, d.findElements(By.tagName("iframe")).size());

    // Switch back to the main frame and check it's the right one
    d.switchTo().defaultContent();
    assertEquals(2, d.findElements(By.tagName("iframe")).size());

    // Switch to the second frame via it's "frame number"
    d.switchTo().frame(1);
    assertEquals(1, d.findElements(By.tagName("title")).size());
    assertEquals(0, d.findElements(By.tagName("iframe")).size());
    assertTrue(d.getPageSource().contains("WYSIWYG Editor Input Template"));

    // Switch again to the main frame
    d.switchTo().defaultContent();
    assertEquals(2, d.findElements(By.tagName("iframe")).size());
  }
Beispiel #3
0
 @Override
 public void checkAfterLogout(String lang) {
   // Check bye msg
   assertEquals(
       "h2 element text doesn't match",
       getLabelText(lang, "LL_BYE_BYE"),
       driver.findElement(By.tagName("h2")).getText());
 }
  @Test
  public void shouldBeAbleToSwitchToIFrameThatHasNoNameNorId() {
    server.setGetHandler(
        new HttpRequestCallback() {
          @Override
          public void call(HttpServletRequest req, HttpServletResponse res) throws IOException {
            res.getOutputStream()
                .println("<html>" + "<body>" + "   <iframe></iframe>" + "</body>" + "</html>");
          }
        });

    WebDriver d = getDriver();
    d.get(server.getBaseUrl());

    WebElement el = d.findElement(By.tagName("iframe"));
    d.switchTo().frame(el);
  }