Example usage for org.openqa.selenium WebElement getTagName

List of usage examples for org.openqa.selenium WebElement getTagName

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getTagName.

Prototype

String getTagName();

Source Link

Document

Get the tag name of this element.

Usage

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs//w  w  w .j  a va2  s  .c  om
 */
@Test
public void clickNestedElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <span id='theSpan'>My Link</span>\n" + "  </a>\n" + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement span = driver.findElement(By.id("theSpan"));
    assertEquals("span", span.getTagName());
    span.click();
    assertEquals(URL_FIRST + "page2.html", driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs/* ww w . j  a v  a2 s  .c  o m*/
 */
@Test
public void clickNestedButtonElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <button id='theButton'></button>\n" + "  </a>\n" + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement button = driver.findElement(By.id("theButton"));
    assertEquals("button", button.getTagName());
    button.click();
    assertEquals(URL_FIRST + "page2.html", driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs/*from  ww w .  j  a va  2 s .  c om*/
 */
@Test
@Alerts(DEFAULT = "", FF = "page2.html")
public void clickNestedCheckboxElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <input type='checkbox' id='theCheckbox' name='myCheckbox' value='Milk'>\n" + "  </a>\n"
            + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement checkbox = driver.findElement(By.id("theCheckbox"));
    assertEquals("input", checkbox.getTagName());
    checkbox.click();
    assertEquals(URL_FIRST + getExpectedAlerts()[0], driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs/*  w  w  w  . java 2 s.  c  o m*/
 */
@Test
public void clickNestedImageElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <img id='theImage' src='test.png' />\n" + "  </a>\n" + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement img = driver.findElement(By.id("theImage"));
    assertEquals("img", img.getTagName());
    img.click();
    assertEquals(URL_FIRST + "page2.html", driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs/* w  ww . ja v  a  2s  .  c  o m*/
 */
@Test
@Alerts(DEFAULT = "page2.html", IE = "")
public void clickNestedInputImageElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <input type='image' id='theInput' />\n" + "  </a>\n" + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement input = driver.findElement(By.id("theInput"));
    assertEquals("input", input.getTagName());
    input.click();
    assertEquals(URL_FIRST + getExpectedAlerts()[0], driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs/*from  w ww .ja  v a2 s  . co m*/
 */
@Test
@Alerts(DEFAULT = "page2.html", IE = "")
public void clickNestedInputTextElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <input type='text' id='theInput' />\n" + "  </a>\n" + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement input = driver.findElement(By.id("theInput"));
    assertEquals("input", input.getTagName());
    input.click();
    assertEquals(URL_FIRST + getExpectedAlerts()[0], driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs//from  w  ww  .j a  v a  2s  .co m
 */
@Test
@Alerts(DEFAULT = "page2.html", IE = "")
public void clickNestedInputPasswordElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <input type='password' id='theInput' />\n" + "  </a>\n" + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement input = driver.findElement(By.id("theInput"));
    assertEquals("input", input.getTagName());
    input.click();
    assertEquals(URL_FIRST + getExpectedAlerts()[0], driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs//w w w  .  j a v a  2  s. c o m
 */
@Test
public void clickNestedOptionElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n" + "    <select>\n"
            + "      <option id='theOption'>test</option>\n" + "    </select>\n" + "  </a>\n"
            + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement option = driver.findElement(By.id("theOption"));
    assertEquals("option", option.getTagName());
    option.click();
    assertEquals(URL_FIRST + "page2.html", driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs/*from w  w  w  .j ava  2s  .co  m*/
 */
@Test
@Alerts(DEFAULT = "", FF = "page2.html")
public void clickNestedRadioElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <input type='radio' id='theRadio' name='myRadio' value='Milk'>\n" + "  </a>\n"
            + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement radio = driver.findElement(By.id("theRadio"));
    assertEquals("input", radio.getTagName());
    radio.click();
    assertEquals(URL_FIRST + getExpectedAlerts()[0], driver.getCurrentUrl());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java

License:Apache License

/**
 * @throws Exception if an error occurs// www  .j ava  2 s  .  c om
 */
@Test
@Alerts("page2.html")
public void clickNestedResetElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <input type='reset' id='theInput' />\n" + "  </a>\n" + "</body></html>";

    getMockWebConnection().setDefaultResponse("");
    final WebDriver driver = loadPage2(html);
    final WebElement input = driver.findElement(By.id("theInput"));
    assertEquals("input", input.getTagName());
    input.click();
    assertEquals(URL_FIRST + getExpectedAlerts()[0], driver.getCurrentUrl());
}