I have a method that uses the Actions class to access a sub menu link. After hovering the main menu link I need to pause before clicking on the sub menu link. So I added a thread.sleep(). At this point the IDE throws an exception with 2 quick fixes as a suggestion:
"Add throws exception" or "surround with try catch block".
Which one should I use?
Here is the method:
public void goToAddNewPost() {
Actions actions = new Actions(driver);
WebElement menuHoverLink = driver.findElement(posts);
actions.moveToElement(menuHoverLink).build().perform();
Thread.sleep(500);
WebElement subLink = driver.findElement(addNew);
actions.moveToElement(subLink).click().build().perform();
}