- Learn Selenium
- Unmesh Gundecha Carl Cocchiaro
- 148字
- 2021-06-24 13:25:49
Listening for the clicked WebElement
This event occurs when a WebElement is clicked, that is, by executing webElement.click(). There are two methods to listen for this event in the WebDriverEventListener implementation:
public void beforeClickOn(WebElement element, WebDriver driver)
The preceding method is invoked when the WebDriver is about to click on a particular WebElement. The WebElement that is going to be clicked on and the WebDriver that is clicking on it are sent as parameters to this method so that the test-script developer can interpret which driver performed the click action, and on which element the action was performed:
public void afterClickOn(WebElement element, WebDriver driver)
The EventFiringWebDriver class notifies the preceding method after the click action is taken on a WebElement. Similar to the beforeClickOn() method, this method is also sent the WebElement and WebDriver instances. If an exception occurs during a click event, this method is not called.