Skip to content

Commit 1e8406a

Browse files
committed
[test] fix race condition in iframe-remote tests
1 parent e90859f commit 1e8406a

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

test/sanity/iframe-remote-neg/test.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,22 @@
4444
result = driver.find_element_by_id('res1').get_attribute('innerHTML')
4545
print result
4646
assert("ENABLED" in result)
47-
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
48-
result2 = wait_for_element_id(driver, 'res2')
49-
print result2
50-
assert("DISABLED" in result2)
47+
timeout = 10
48+
ret = ''
49+
elem_id = 'res2'
50+
while timeout > 0:
51+
try:
52+
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
53+
ret = driver.find_element_by_id(elem_id).get_attribute('innerHTML')
54+
break
55+
except selenium.common.exceptions.NoSuchElementException:
56+
pass
57+
time.sleep(1)
58+
timeout = timeout - 1
59+
if timeout <= 0:
60+
raise Exception('Timeout when waiting for element' + elem_id)
61+
print ret
62+
assert("DISABLED" in ret)
5163
finally:
5264
server.terminate()
5365
driver.quit()

test/sanity/iframe-remote/test.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,22 @@
4444
result = driver.find_element_by_id('res1').get_attribute('innerHTML')
4545
print result
4646
assert("ENABLED" in result)
47-
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
48-
result2 = wait_for_element_id(driver, 'res2')
49-
print result2
50-
assert("ENABLED" in result2)
47+
timeout = 10
48+
ret = ''
49+
elem_id = 'res2'
50+
while timeout > 0:
51+
try:
52+
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
53+
ret = driver.find_element_by_id(elem_id).get_attribute('innerHTML')
54+
break
55+
except selenium.common.exceptions.NoSuchElementException:
56+
pass
57+
time.sleep(1)
58+
timeout = timeout - 1
59+
if timeout <= 0:
60+
raise Exception('Timeout when waiting for element' + elem_id)
61+
print ret
62+
assert("ENABLED" in ret)
5163
finally:
5264
server.terminate()
5365
driver.quit()

0 commit comments

Comments
 (0)