bdd - Wait for a response during a feature test using lettuce+splinter and django -
short story: writing feature test django app using lettuce , splinter. scenario fails due lack of sync @ step calls.
the question: there way prevent error happening wihtout adding artificial waiting time step?
longer story: scenario checks if existing user able log in.
scenario: user exists admin given access url "/login/" , user "someuser" password "something" exists admin when fill username "someuser" , password "exists" , submit form see paragraph "you're logged in!"
the critical step here is:
@step(r'i see paragraph "(.*)"') def see_paragraph(step, text): assert text in world.browser.html
when harvest lettuce feature, randomly fails.
traceback (most recent call last): file "/usr/local/lib/python2.7/dist-packages/lettuce/core.py", line 143, in __call__ ret = self.function(self.step, *args, **kw) file "/vagrant/src/enext/apps/auth/features/authentication-steps.py", line 21, in see_paragraph assert text in world.browser.html assertionerror
when tried debug it, found printing response make work every time, not reproduce error. adding pause seems trick.
@step(r'i see paragraph "(.*)"') def see_paragraph(step, text): # print world.browser.html.encode('utf-8') # either next or previous line fixes time.sleep(0.3) assert text in world.browser.html
at first looked related test database flush, removed other scenarios, , flush well, , kept happening.
it might depend on and submit form
makes. if step clicks on "submit" button or it's place problem starts.
webdriver waits page load after actions except clicking , other "onpage" interactions. after click looks presence of element without waiting response.
as solution recommend use wait_time
argument described @ splinter docs or write own function goes in loop of checking statement until specified timeout.
p.s.: recommend @ python selenium , it's wait(browser, timeout).until(some_statement)
Comments
Post a Comment