I'm writing some automated tests for using the selenium chrome driver. I trying to write a reusable method that will explicitly wait for elements to appear and then call this method in other classes. Seems pretty straight forward but its not doing what I want it do. Here is the method that I have.
public String waitForElement(String item) { WebDriverWait wait = new WebDriverWait(driver,30); WebElement element = wait.until( ExpectedConditions.elementToBeClickable(By.id(item))); return item; } Then I call the method and pass it a parameter like this:
waitForElement("new-message-button"); That doesn't seem to become working, can someone give some insight?
itemis what you want to return? When I've written code like this, what I wanted would be what is namedelementin your code.elementget found?