Skip to main content

Posts

Showing posts with the label webelement

Reliable way to click on WebElement in Selenium Webdriver

Introducing a more robust way to click on the WebElement in situations when the native WebDriver click method doesn't work for some unknown yet obscure and annoying reason. Example of implementation in C# is given below. Probably porting of this code to Java wouldn't take too much time as well. Everything you need is a getter method with a CSS selector, which is automatically converted into Xpath in generateXpath method, and then the click event is triggered using JavaScript evaluate in ClickJS method. Works like a charm, also makes my tests more robust, especially in a multithreaded mode.