What's the problem?
Im currently trying to scrape data from a subreddit (I am using the old-reddit chrome-extension that gives back the old look of reddit -> this way it's easier to scrape), but whenever I'm trying to get the results I get the error from this little bit of code:
xpath = "//a[@class='title may-blank loggedin ']"
element = driver.find_element_by_xpath(xpath)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@class='title may-blank loggedin ']"}
What did I try to fix the problem?
I already saw many posts with similar errors, often related with scraping the results before the page was loaded. I tried to fix that with:
time.sleep(20)
But still no diffrence.
The path is correct as well. I entered the same path on Chrome's console and it displayed correct results.
When I search for tag names, class names etc., I get correct results as well.
Thank you for your help in advance!!
Stack trace
Traceback (most recent call last):
File "D:\Web_Dev\Projekte\cs50_project\test.py", line 68, in <module>
main()
File "D:\Web_Dev\Projekte\cs50_project\test.py", line 32, in main
element = driver.find_element_by_xpath(xpath)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\selenium\webdriver\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":"xpath","selector":"//a[@class='title may-blank loggedin ']"}
(Session info: chrome=88.0.4324.150)