I have a function below that clicks the submit button on a form on my page. In order to successfully submit the form, a document must be attached. However, depending on how the database is linked sometimes, saved documents don't populate as already having been uploaded.
This is a minor detail, priority is to submit the form. I created an if statement, to check whether the upload button is present. If it is, then the it should upload a file from my computer, and then click the submit button. If its not, then it should just click the submit button.
This works, when the upload button is present. However, when its not, it gets stuck on the if condition and doesn't get to the else clause.
def submit_draw_request(driver, document_file_path):
if EC.visibility_of_element_located((By.XPATH, "//button[text()='Upload']")):
shared.upload_file_from_computer(driver, "//input[@class='MultipleFileUploadWidget']", document_file_path)
time.sleep(2)
shared.click_button(driver, elements.submit_button)
else:
time.sleep(2)
shared.click_button(driver, elements.submit_button)
Aucun commentaire:
Enregistrer un commentaire