Introduction
Retrieving integer values from fields in Selenium can be a tricky task. Fortunately, there are a few methods that can be used to make this process easier. In this article, we will discuss how to retrieve integer values from fields in Selenium using various techniques. We will also discuss the advantages and disadvantages of each method. By the end of this article, you should have a better understanding of how to retrieve integer values from fields in Selenium.
Solution
You can retrieve an integer value from a field in Selenium using the getAttribute() method. This method takes the name of the attribute as an argument and returns the value of the attribute as a string. To convert the string to an integer, you can use the Integer.parseInt() method.
Example:
String value = driver.findElement(By.id(“fieldId”)).getAttribute(“value”);
int intValue = Integer.parseInt(value);
Looking at your code you are trying to print the element itself.
System.out.println(FatherNum);
If you want to print the value of that field , you can do it by :
System.out.println(FatherNum.getAttribute("value"));
OR
String Fathernum= FatherNum.getAttribute("value");
System.out.println(Fathernum);
See the doc for getAttribute – see link
1
solved How to retrieve integer value from field in selenium?