- 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
推薦閱讀
- FreeSWITCH 1.2
- Web安全防護(hù)指南:基礎(chǔ)篇
- 光網(wǎng)絡(luò)評(píng)估及案例分析
- Truffle Quick Start Guide
- Proxmox High Availability
- 網(wǎng)絡(luò)安全技術(shù)與解決方案(修訂版)
- 計(jì)算機(jī)網(wǎng)絡(luò)工程實(shí)用教程(第2版)
- 通信原理及MATLAB/Simulink仿真
- 光纖通信系統(tǒng)與網(wǎng)絡(luò)(修訂版)
- SAE原理與網(wǎng)絡(luò)規(guī)劃
- 中國(guó)互聯(lián)網(wǎng)發(fā)展報(bào)告2021
- Dart Cookbook
- 計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)
- Getting Started with tmux
- 精通SEO:100%網(wǎng)站流量提升密碼