Can we make selenium webdriver to wait until user clicks on a webpage link at run-time without using implicit wait?
java, selenium, selenium-webdriver
Solution
Selenium webdriver is a tool used to Automate tests on web based applications,which means even human interactions are automated.
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available.
This means you cannot use this to wait for human interactions. But you can assume that the user is waiting for some link to appear and call click().
This can be achieved using Explicit wait.
An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code.
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.linkText("some_link")));
element.click();
The above code waits for 30 secs for the link to appear and to be clickable.
Refer to the documentation for more info.
Problem
I am using Firefox driver with java and trying to scrape some data from a website. There is a human interaction involved in it and I have to ask the user to input a search string. And then accordingly user has to select which search result to open by analyzing with human eye. The effort is just to make few bits and pieces work faster through script. My question is: Can we make selenium webdriver to wait until user clicks on a webpage link at run-time without using implicit wait? I can not use implicit wait because the time for click may vary from few seconds to few minutes. I am new to both java and selenium. Your help will be much appreciated. - Thanks