问题描述:

I face with this InvalidElementStateException from time to time at this spot:

WebElement webElement...

webElement.clear()

So i was thinking about this solution:

 def clearTextFieldAndRecoverFromInvalidElementState(webElement: WebElement): Unit = {

var count = 0

var result = false

breakable {

while (count < 3 && !result) {

try {

webElement.clear()

result = true

} catch {

case e: InvalidElementStateException => println("Trying to recover from a InvalidElementStateException")

count = count + 1

Thread.sleep(2000)

}

}

}

}

相关阅读:
Top