My explicit wait isn't waiting until the element is present. It literally waits the amount of seconds I declared and then the tests still fails. If I place a implicit wait in the exact same place the test passes. From what I'm reading, it's best practise to avoid implicit waits as much as possible. Am I doing something wrong?
I have made a method in the base_page like so:
def _wait_for_is_displayed(self, locator, timeout):
try:
wait = WebDriverWait(self.driver, timeout)
wait.until(expected_conditions.visibility_of_element_located((locator["by"], locator["value"])))
except TimeoutException:
return False
return True
then i call the _wait_for_is_displayed method in a page object like so, but fails:
def relatie_page_present(self):
self._wait_for_is_displayed(self._open_actieve_polissen_tab, 10)
def relatie_page_(self):
self._click(self._open_relatie_details)
self.relatie_page_present()
The error I get is:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"td.first > a"}
This passes:
def relatie_page_present(self):
self.driver.implicitly_wait(10)
def relatie_page_(self):
self._click(self._open_relatie_details)
self.relatie_page_present()
Lastly in my test suite i call the relatie_page_present and relatie_page_ methods.