Check the existence of an element with Selenium

Asked

Viewed 2,713 times

2

I am automating a site 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 these values. What I want is to make the system check if this table exists for each of the options and if it exists take its values, but when I try to give a Findelement, If the table does not exist in a given option instead of just following it it throws the error n have found for the catch. How do I give Findelement only after I know that this table is present?

1 answer

1


Assuming your table ID is idDaSuaTabela, you need wait for the table appear until further:

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

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

  • Vlw help but already got, I created in Try catch and Finally just to check this, ai qnd he n thought he played in catch, Finally and followed the system

Browser other questions tagged

You are not signed in. Login or sign up in order to post.