21
21
22
22
from selenium .webdriver .common .by import By
23
23
from selenium .webdriver .remote .webelement import WebElement
24
+ from selenium .webdriver .support import expected_conditions as EC
25
+ from selenium .webdriver .support .wait import WebDriverWait
24
26
25
27
26
28
@pytest .fixture
@@ -39,9 +41,8 @@ def test_can_upload_file(driver, pages, get_local_path):
39
41
driver .find_element (By .ID , "upload" ).send_keys (get_local_path ("test_file.txt" ))
40
42
driver .find_element (By .ID , "go" ).click ()
41
43
driver .switch_to .frame (driver .find_element (By .ID , "upload_target" ))
42
- body = driver .find_element (By .CSS_SELECTOR , "body" ).text
43
44
44
- assert " test_file.txt" in body
45
+ WebDriverWait ( driver , 10 ). until ( EC . text_to_be_present_in_element (( By . CSS_SELECTOR , "body" ), " test_file.txt"))
45
46
46
47
47
48
def test_can_upload_two_files (driver , pages , get_local_path ):
@@ -50,10 +51,9 @@ def test_can_upload_two_files(driver, pages, get_local_path):
50
51
driver .find_element (By .ID , "upload" ).send_keys (two_file_paths )
51
52
driver .find_element (By .ID , "go" ).click ()
52
53
driver .switch_to .frame (driver .find_element (By .ID , "upload_target" ))
53
- body = driver .find_element (By .CSS_SELECTOR , "body" ).text
54
54
55
- assert " test_file.txt" in body
56
- assert " test_file2.txt" in body
55
+ WebDriverWait ( driver , 10 ). until ( EC . text_to_be_present_in_element (( By . CSS_SELECTOR , "body" ), " test_file.txt"))
56
+ WebDriverWait ( driver , 10 ). until ( EC . text_to_be_present_in_element (( By . CSS_SELECTOR , "body" ), " test_file2.txt"))
57
57
58
58
59
59
@pytest .mark .xfail_firefox
0 commit comments