简体   繁体   中英

unable to locate element : selenium in python

I'm a newbie in coding with python and selenium. I try to find an element in a web-page by its class name.

    <input type="email" class="whsOnd zHQkBf" jsname="YPqjbf" 
           autocomplete="username" spellcheck="false" tabindex="0" 
           aria-label="Adresse e-mail ou numéro de téléphone" name="identifier" 
           value="" autocapitalize="none" id="identifierId" dir="ltr" 
           data-initial-dir="ltr" data-initial-value="">

But each time I've tried I have this error.

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".whsOnd zHQkBf"}

I don't understand why because I verified and I think that it's not in an iframe so I don't understand why do I have this message and I don't know how to manage the error.

Here are the pictures of my code and the html:

My code

The HTML of the page

Hard to tell without seeing your code and the html. Are you sure it is not in a iframe?

If not you can perhaps try to use xpath to find the element. When inspecting the webpage in chrome you can right click the element and say copy -> copy xpath. I do recommend looking into xpath, so you know what you are searching for.

Edit: Try using only one class name, since find_element_by_class_name() only accepts one.

This: driver.find_element_by_class_name("zHQkBf")

instead of this: driver.find_element_by_class_name("whsOnd zHQkBf")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM