I'm using Selenium to upload an excel file to a website automatically. To make sure upload is complete before proceeding i use time.sleep(60)
but i want to make the code a bit smarter.
after the upload field, there's a label element.
<label id="upload_status">only .xlsx files will be accepted.</label>
this label changes after upload is finished to
<label id="upload_status">100 entries were detected.</label>
can i use the text inside the label to tell if the upload has finished?
CodePudding user response:
Yes, you can use text_to_be_present_in_element
expected_conditions
.
This should work:
WebDriverWait(driver, 100).until(EC.text_to_be_present_in_element((By.ID, "upload_status"), "entries were detected"))
These imports should be used here:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC