- 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
推薦閱讀
- 數(shù)據(jù)通信網(wǎng)絡(luò)實踐:基礎(chǔ)知識與交換機(jī)技術(shù)
- 物聯(lián)網(wǎng)短距離無線通信技術(shù)應(yīng)用與開發(fā)
- Wireshark網(wǎng)絡(luò)分析就這么簡單
- 區(qū)塊鏈輕松上手:原理、源碼、搭建與應(yīng)用
- 網(wǎng)絡(luò)基礎(chǔ)與網(wǎng)絡(luò)管理項目化教程
- The Kubernetes Workshop
- jQuery Mobile Web Development Essentials
- 6G:面向2030年的移動通信
- 4G小基站系統(tǒng)原理、組網(wǎng)及應(yīng)用
- 物聯(lián)網(wǎng)與智能家居
- Learning Windows 8 Game Development
- 圖神經(jīng)網(wǎng)絡(luò)前沿
- SRv6網(wǎng)絡(luò)部署指南
- Python API Development Fundamentals
- 算力網(wǎng)絡(luò):云網(wǎng)融合2.0時代的網(wǎng)絡(luò)架構(gòu)與關(guān)鍵技術(shù)