I am trying to automate a websearch, where company names are taken from an excel sheet, listed in one column and inserted into the web search mask. The second step is to take a specific information from the search option. With a single, direct input of a company name in the code, the code is working. However, i have problems to iterate through the excel sheet columns to get the input for the search mask.Every help would be appreciated. What I have so far is this:
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options = Options()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument('headless')
url = "https://google.com/finance"
driver.get(url)
# automatically agree to the cookie pop-up to close it
button = driver.find_element_by_name('agree')
button.click()
df= pd.read_excel("C:\Test.xlsx",
sheet_name= 'Sheet1',
index_col='Company')
for i in 'Company':
WebDriverWait(driver, 2).until(EC.element_to_be_clickable((By.XPATH, "//input[@jsname='VYoA2e']"))).send_keys('Company')
auto_suggest = WebDriverWait(driver, 2).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@class='MkjOTb hQVKs']")))
list_new = []
for item in auto_suggest:
list_new.append(item.text)
Aucun commentaire:
Enregistrer un commentaire