selenium cant find element - no such element

Viewed 74

I have this website where I want to get the element post-title.

I tried driver.find_element_by_class_name("sc-1di2uql-1 vYcWR") but that just returns: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".sc-1di2uql-1 vYcWR"}

I have seen similar posts where the problem was that the searched element was in an iframe but I cant see anything like that here. Then again I started to learn about webscraping about a week ago so theres probably a lot I dont know.

1 Answers

I had a similar issue with selenium before. My problem was that the website would rotate class names, so every time you access the page they would be different. Judging by the way the class names are on your website I think you have the same issue. If this is the case, you are just trying to look for something that is not there. What I did to solve this problem was using driver.get_element_by_xpath(“PASTE FULL XPATH OF THE ELEMENT”) instead of finding the element using its css class.

To get the full path of an element: in the developer tools, right click on the element and click copy FULL XPATH.

Related