1

Im trying to get an specific email from a gmail address (or subject). Im using selenium because can't use imaplib for this gmail account. Im stck here:

driver.find_element_by_id("identifierId").send_keys('MYEMAIL')
driver.find_element_by_id("identifierNext").click()

time.sleep(5)
driver.find_element_by_name("password").send_keys('PSWRD')
driver.find_element_by_id("passwordNext").click()

time.sleep(15)

email = driver.find_elements_by_css_selector("div.xT>div.y6")

for emailsub in email:    
     if "someone@gmail.com" in emailsub:   #Error line
     emailsub.click()
     break

Error: argument of type 'WebElement' is not iterable

Idk why I'm using find_elements.

sshashank124
  • 31,495
  • 9
  • 67
  • 76
Luis Angel
  • 11
  • 1

1 Answers1

0

Your for is loop being done correctly and they way you call driver.find_elements_by_css_selector is fine. Inside of your for loop you are dealing with INDIVIDUAL instances of WebElement. The error you get is due to the use of the in statement, I would check this post on using IN in a IF statement and furter understand what you are looking for in your in statement.

I suspect plainly iterating over the WebElement class is throwing this error, and you need to further define what the `in' applies to.

William
  • 16
  • 2