How to click with Selenium Webdriver and Java

I am doing automated tasks.

To finish my task, I want to execute 3 automatic clicks in the same pop-up. The last one fails many times. Sometimes it is not able to click or does it outside the button.

I have also tried thread.sleep and the problem continues.

My code:

WebElement boton = driver.findElement(By.xpath(PATH_BOTON));
WebDriverWait wait3 = new WebDriverWait(driver, 2);

CSS selector or Javascript executor are better options?

Read more here: Source link