Skip to content

Commit a26d761

Browse files
committed
[test] fix race conditions in additional-trust-anchors
1 parent 1e8406a commit a26d761

File tree

1 file changed

+19
-4
lines changed
  • test/sanity/additional_trust_anchors

1 file changed

+19
-4
lines changed

test/sanity/additional_trust_anchors/test.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import os
33
import subprocess
44
import platform
5+
import sys
6+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
7+
from nw_util import *
58

69
from selenium import webdriver
710
from selenium.webdriver.chrome.options import Options
@@ -56,12 +59,24 @@ def write_file(filename, content):
5659
try:
5760
try:
5861
print driver.current_url
59-
driver.switch_to_frame(driver.find_element_by_id('test-frame'))
62+
timeout = 10
63+
ret = ''
64+
elem_id = 'result'
65+
while timeout > 0:
66+
try:
67+
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
68+
ret = driver.find_element_by_id(elem_id).get_attribute('innerHTML')
69+
break
70+
except selenium.common.exceptions.NoSuchElementException:
71+
pass
72+
time.sleep(1)
73+
timeout = timeout - 1
74+
if timeout <= 0:
75+
raise Exception('Timeout when waiting for element' + elem_id)
6076
title = driver.execute_script('return document.title')
6177
print title
62-
result = driver.find_element_by_id('result').get_attribute('innerHTML')
63-
print result
64-
assert('success' in result)
78+
print ret
79+
assert('success' in ret)
6580
driver.close()
6681
finally:
6782
driver.quit()

0 commit comments

Comments
 (0)