- Learn Selenium
- Unmesh Gundecha Carl Cocchiaro
- 135字
- 2021-06-24 13:25:49
Listening for WebElement value changes
This event occurs when the value of a WebElement changes when the sendKeys() or clear() methods are executed on them. There are two methods associated with this event:
public void beforeChangeValueOf(WebElement element, WebDriver driver)
The preceding method is invoked before the WebDriver attempts to change the value of the WebElement. As a parameter, the WebElement itself is passed to the method so that you can log the value of the element before the change:
public void afterChangeValueOf(WebElement element, WebDriver driver)
The preceding method is the second method associated with the value-change event that is invoked after the driver changes the value of the WebElement. Again, the WebElement and the WebDriver are sent as parameters to the method. If an exception occurs when changing the value, this method is not invoked.