Sep-14-2020, 05:28 AM
I want to do a search for every element in an array
My code works and searches for the first element in the array only
Any ideas why it does not work for further elements?
My code works and searches for the first element in the array only
Any ideas why it does not work for further elements?
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import NoSuchElementException import time PATH = "C:\Program Files (x86)\chromedriver.exe" driver = webdriver.Chrome(PATH) driver.get("https://www.bing.com/search?q=test&form=QBLH&sp=-1&pq=test&sc=8-4&qs=n&sk=&cvid=E4AB1C52851A40EDB1B619B0CC4374A2") time.sleep(5) el = driver.find_element_by_xpath("//*[@id=\"sb_form_q\"]") time.sleep(10) codes = ['alpha', 'beta', 'gamma'] for code in codes: try: el.clear() el.send_keys(code) el.send_keys(Keys.RETURN) time.sleep(10) except: print('error') pass