- Selenium WebDriver 3 Practical Guide
- Unmesh Gundecha Satya Avasarala
- 156字
- 2021-08-13 16:08:10
The getTagName() method
The getTagName method can be called from all the WebElements. This will return the HTML tag name of the WebElement. For example, in the following HTML code, the button is the tag name of the HTML element:
<button id="gbqfba" class="gbqfba" name="btnK" aria-label="Google Search">
In the preceding code, the button is the tag name of the HTML element.
The API syntax for the getTagName() method is as follows:
java.lang.String getTagName()
The return type of the preceding method is String, and it returns the tag name of the target element.
The following is the code that returns the tag name of the Search button:
@Test
public void elementGetTagNameExample() {
WebElement searchButton = driver.findElement(By.className("search-button"));
System.out.println("Html tag of the button is: "
+ searchButton.getTagName());
}
The preceding code uses the getTagName() method to get the tag name of the Search button element. The output of the code is as expected:
Html tag of the button is: button
推薦閱讀
- 黑客攻防實戰技術完全手冊:掃描、嗅探、入侵與防御
- 解析QUIC/HTTP3:未來互聯網的基石
- C++黑客編程揭秘與防范
- Go Web Scraping Quick Start Guide
- 網絡安全應急響應技術實戰
- Microservice Patterns and Best Practices
- 網絡環境中基于用戶視角的信息質量評價研究
- Learning Windows 8 Game Development
- Scala Design Patterns.
- 大型企業微服務架構實踐與運營
- 異構蜂窩網絡關鍵理論與技術
- Microsoft Power Platform Enterprise Architecture
- 設備監控技術詳解
- RestKit for iOS
- 走近奇妙的物聯網