Is there a way in Selenium to determine the type of tag? On my automation page, some fields may change their type. For example, if the first field value is greater, the second field becomes an input text; if the first is "IN", then a dropdown appears. So, is there a method using JavaScript executor to find the tag name from the identified element?
I have tried the following 2 methods:
WebElement ele = driver.findElement(By.id("identifierId"));
String tag = (String) ((JavascriptExecutor) driver).executeScript("return ele.tagName");
System.out.println(tag);
2) Using XPath:
String xpath = "input[id='identifierId']";
String mainURL = (String) ((JavascriptExecutor) driver).executeScript("return (document.querySelector(\"xpath \").tagName)");
Is there a solution for this?