pytest-dev/pytest-splinter

Implicit wait_for_condition

Closed this issue · 7 comments

I am having to add a "wait_for_condition" before a "find_by" in many places after arbitrary test failures.

Can this be made implcit? like an additional wait=True for the find_by function?

Do you think this is a good idea? Any other way to do this?

implicit wait is already there and enabled
just it depends on how exactly you work with browser object
to fully use it, your search expression should be full, like:

    assert browser.find_by_xpath("//div[@class='message success' and contains(text(), 'Saved.')]")

instead of

    assert browser.find_by_xpath("//div[@class='message success']").text ==  'Saved.'

feel the difference. First variant will use implicit wait feature of selenium, the second - only in part of finding the div, but not the div with the text

Thank you. Let me see if i can remove by wait_for_condition(s) using this.

What about methods such as find_link_by_text(). Found intermittent failures until I put a wait_for_condition. Should I change these to find_by_xpath()?

    def find_link_by_text(self, text):
        return self.find_by_xpath(
            '//a[text()="%s"]' % text, original_find="link by text", original_query=text)

it's implementation already uses xpath, so it's fine
may be in this case you just need to increase implicit wait?

--splinter-implicit-wait
Selenium webdriver implicit wait. Seconds (default: 1).

1 second is not always enough

try with 5 via command line
if it helps, override a fixture (splinter_selenium_implicit_wait) to have it permanent

probably it makes sense to increase the default implicit wait timeout btw

probably it makes sense to increase the default implicit wait timeout btw

3 or 5 might be a better default, yes.
But it can lead to too much waiting in general, depending on your tests.
So I'd vote for use 3 as a compromise.

Agree
In paylogic we use 5 but 3 should be sufficient
On May 2, 2015 1:09 AM, "Daniel Hahler" notifications@github.com wrote:

probably it makes sense to increase the default implicit wait timeout btw

3 or 5 might be a better default, yes.
But it can lead to too much waiting in general, depending on your tests.
So I'd vote for use 3 as a compromise.


Reply to this email directly or view it on GitHub
#26 (comment)
.