I am trying to iterate through a list, this code block is part of a for loop - what I'm trying to accomplish is that if an element is not present go to the next item in the list. I'm testing it with two pages in a list, the first iteration does contain the class 'buggybox' however the second when then for loop gets to the second itteration len(warning) is still being printed even and the loop doesn't get to the else statement. I suspect it's an issue with my python code rather than it being a selenium issue. Either way I would be grateful for some help.
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, 'windowAutomatch')))
run_automatch_button = driver.find_element_by_id('btnRunAutomatch')
run_automatch_button.click()
warning = driver.find_elements_by_class_name('buggybox')
if len(warning):
print(len(warning))
continue
else:
#Saves suggested matches
print(len(warning))
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, 'windowConfirmAutomatch')))
save_suggested_matches_button = driver.find_element_by_link_text('Save Suggested Matches')
print('found')
driver.execute_script("arguments[0].click();", save_suggested_matches_button)
WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((By.ID, 'windowConfirmAutomatch')))
print("AutoMatch Complete for " + fund)
Aucun commentaire:
Enregistrer un commentaire