I’m trying to write my first script for Selenium/Python, so no doubt this is a very silly question. I’m trying to find the element that says “Club Pilot Airmanship” in the following HTML:
It gives the error: File “C:\Users\RowanB\AppData\Roaming\Python\Python38\site-packages\selenium\w ebdriver\remote\errorhandler.py”, line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {“method”:“css selector”,“selector”:".css-api-card-header __title"} (Session info: chrome=84.0.4147.125)
Why is it not finding the element? What do I have to do to fix this?
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
See this post to find the backtick on your keyboard. Note: Backticks (`) are not single quotes (’).
As for your question, I cannot see any element within the HTML you have pasted with a class of css-api-card-header__title. Can you point this element out?
With Selenium, I remember having best success with using the XPath. If you are using Chrome, the element XPath is as easy to find as right-clicking an HTML element in the element tree -> Copy -> By XPath.