python - How can we wait for a message text to pop up in selenium -
i have selenium application contains uploads file function gets called recursively after every upload on website
problem:
the function being called , not waiting upload done. messing whole application process. know can add time.sleep() not know size of files , how long upload take. prefer add check see if files uploaded
my solution
luckily me successful message pops when uploads done
so decided add success_element waits success message pop out seen in code below
def upload(driver, filenum, filepath): #click ok upload ok_link = driver.find_element_by_class_name("borderbutton") ok_link.click() #wait success message pop out( fails ) success_wait = webdriverwait(driver, 1200) success_element = success_wait.until(ec.visibility_of_element_located(by.link_text("file(s) have(s) been uploaded successfully!"))) #call function again upload more after succesful message pops out upload(driver, filenum, filepath) error:
i got error below right after first group of files uploaded, because did not find success message right away, not supposed anyway , thought wait after upload done 1200 seconds (roughly 20 minutes max)
how can solve problem. other solutions ?
success_element = success_wait.until(ec.visibility_of_element_located(by.link_text("file(s) have(s) been uploaded successfully!"))) typeerror: 'str' object not callable
for whom had same issue found solution, , using ec.presence_of_element_located instead. waits element located or throws error after 20 minutes
success_wait = webdriverwait(driver, 1800) success_element = success_wait.until(ec.presence_of_element_located((by.id, "successmessage"))) 
Comments
Post a Comment