Skip to content

Commit 39fee38

Browse files
authored
[py] Fixed Flaky Upload Tests (#14706)
1 parent cde43bc commit 39fee38

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

py/test/selenium/webdriver/common/upload_tests.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
from selenium.webdriver.common.by import By
2323
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
2426

2527

2628
@pytest.fixture
@@ -39,9 +41,8 @@ def test_can_upload_file(driver, pages, get_local_path):
3941
driver.find_element(By.ID, "upload").send_keys(get_local_path("test_file.txt"))
4042
driver.find_element(By.ID, "go").click()
4143
driver.switch_to.frame(driver.find_element(By.ID, "upload_target"))
42-
body = driver.find_element(By.CSS_SELECTOR, "body").text
4344

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"))
4546

4647

4748
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):
5051
driver.find_element(By.ID, "upload").send_keys(two_file_paths)
5152
driver.find_element(By.ID, "go").click()
5253
driver.switch_to.frame(driver.find_element(By.ID, "upload_target"))
53-
body = driver.find_element(By.CSS_SELECTOR, "body").text
5454

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"))
5757

5858

5959
@pytest.mark.xfail_firefox

0 commit comments

Comments
 (0)