Right now, I have a method that will wait until an element is visible using:
WebDriverWait(self.driver, seconds).until(lambda s: s.find_element_by_xpath(path).is_displayed())
This works properly; however, it returns a boolean, rather than the element that it found. I would like it to return that element once it is found. I am doing this with the following:
def waituntil(path, seconds):
WebDriverWait(self.driver, seconds).until(lambda s: s.find_element_by_xpath(path).is_displayed())
ret = self.driver.find_element_by_xpath(path)
return ret
Sure, this works. Unfortunately, it requires Selenium to find the same element twice, though, which adds waiting time (no matter how small). Is there a way I can return a web element using a waituntil (or similar functionality) by finding an element only once? So something that would allow the following:
ret = WebDriverWait(self.driver, seconds).until(lambda s: s.find_element_by_xpath(path).is_displayed())
ret.click()
I'm currently using:
Python 2.7
Windows 7
Selenium 2.4.4
Firefox 35.0.1