cakes88
cakes88

Reputation: 1917

Convert WebElement to int

What is the proper way to convert a WebElement to an int? Is this even possible?

Upvotes: 1

Views: 10809

Answers (1)

SiKing
SiKing

Reputation: 10329

This is a java problem, not a Selenium problem. You can use:

driver.findElement(By...locator).getText().toInteger()    // this works in Groovy only

or you can use

Integer.parseInt(driver.findElement(By...locator).getText());    // this works in Java or Groovy

Upvotes: 3

Related Questions