how to acess elemnt in the selenium using its value
Answers
Answered by
0
There are cases where you want to get the attributes values and then perform any action.
In the below, if you see, button tag which has multiple attributes 'name', 'id', 'class' and 'aria-label' and has values for each attribute. To get the attribute value using selenium webdriver, we can use 'element.getAttribute(attributeName)'.
If we try to get the attribute value that doesn't exists for the tag, it will return null value.
In the below, if you see, button tag which has multiple attributes 'name', 'id', 'class' and 'aria-label' and has values for each attribute. To get the attribute value using selenium webdriver, we can use 'element.getAttribute(attributeName)'.
If we try to get the attribute value that doesn't exists for the tag, it will return null value.
Answered by
0
Explanation:
Select select = new Select(driver.findElement(By.xpath("//select")));
WebElement option = select.getFirstSelectedOption();
String defaultItem = option.getText();
System.out.println(defaultItem );
Similar questions