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.HtmlAnchor2Test.java

License:Apache License

/**
 * @throws Exception if an error occurs//from   ww w . j a  va  2s .  com
 */
@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(new URL(getDefaultUrl(), "page2.html").toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs//  w  w w  . ja va 2s  .c o m
 */
@Test
@Alerts(DEFAULT = "page2.html", CHROME = "", IE = "")
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(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs// w w  w.  j  a va 2s  . 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(new URL(getDefaultUrl(), "page2.html").toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs/*from w ww  .java2  s  .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(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs/*w w w.  j  a v  a2  s  .c  o  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(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs/*  w  w w  .ja  v  a  2s .  c  o  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(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs/*  w w  w  .j  a  v  a2  s .co 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(new URL(getDefaultUrl(), "page2.html").toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs/*from   w ww  . jav  a2s .c  o m*/
 */
@Test
@Alerts(DEFAULT = "page2.html", CHROME = "", IE = "")
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(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs//from  w  w w .  ja  va 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(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl());
}

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

License:Apache License

/**
 * @throws Exception if an error occurs//from ww  w .j ava  2s . co m
 */
@Test
@Alerts("page2.html")
public void clickNestedSubmitElement() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "  <a href='page2.html'>\n"
            + "    <input type='submit' 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(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl());
}