Check for an element with Selenium

2

I am automating a website and in a certain part it presents a listbox that when one of its options is selected if it has available values it presents a table with those values. What I want is to make the system check if this table exists for each of the options and if it does pick up its values, but when I try to give a FindElement, if the table does not exist in that particular option instead of it simply following it throws the error of n have found for the catch. How do I give FindElement only after I know that this table is present?

    
asked by anonymous 19.08.2015 / 20:06

1 answer

1

Envisioning that your table ID is idDaSuaTabela , you need to wait for table appear until you continue:

WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("idDaSuaTabela")));

The timeoutInSeconds attribute defines the maximum time, in seconds, that you want to wait for the element.

    
19.08.2015 / 20:11