So, I have a WebElement and I need to check if this element is a positive number; how do I do this in Java using Selenium?
The only thing I was able to do, so far, is a @FindBy(xpath), but I could not do the Actions part cause I have no idea on how to verify if the element is a positive number.
Thanks in advance.
WebElement myElement = driver.findElementByXpath("theXpath");
// or read the attribute value
String text = myElement.getAttribute("text");
int number = Integer.parseInt(text);
if (number > 0) {
// positive
}
else {
// negative
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.