1

Im new in Selenium and im having trouble trying to make a scrape with a "loop for" and using a search bar in a website to run the itens in the list.

Turned the Dataframe in to a list and used the webdriver to access the site

lista_Ean = Ean_01['ean'].tolist()
search = driver.find_element_by_id("search-input")
driver.get('https://cosmos.bluesoft.com.br/')
time.sleep(2)

Then i tried running the loop, the first item in the list runned ok `

for i in lista_Ean:
time.sleep(3)
search.send_keys(i) 
search.send_keys(Keys.RETURN) 
description = driver.find_element_by_id("product_description")
driver.back()

But then it showed this error message

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="search-input"]"}

(Session info: chrome=88.0.4324.104)

I tried also doing using try and except in many different ways. But again im not experienced in using Selenium

try:
descricao = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.id, "descricao"))
)
except (NoSuchElementException):
     driver.back()
    pass
  • Please correct your code for proper indentation in the for-loop and the try-except block. – AcK Jan 27 '21 at 20:30

0 Answers0