What is Tag?
Yes. Tag is the formatting command of the Web Page. This is the heart of the HTML page design. HTML tags include tag for table, tag for input text, tag for paragraph, tags for heading, tag for titles etc. This is enclose by < > and come in pair to specifying beginning and ending.
Now You are clear what is Tag. How you will traverse through Tag to locate an element of the web page.
See the below code.
driver.findElement(By.tagName(“Tag_name”));
Scenario with Example:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class Locator_By_ID { public static void main(String[] args) { WebDriver driver= new ChromeDriver() ; driver.manage().window().maximize(); driver.get("https://www.testinglpoint.com"); login_button= driver.findElement(By.tagName("Name of the Tag"));