Hi, first of all, I apologize to all of you because my English is not good, but I know how to run this code on my own computer, it gives such an error when I type pythonanywhere and I couldn't figure out why.
from pyvirtualdisplay import Display
from selenium import webdriver
with Display():
browser = webdriver.Firefox()
try:
browser.get('https://www.facebook.com/')
element = browser.find_element_by_xpath("//*[@id='reg_pages_msg']/a")
print(element.text)
finally:
browser.quit()
Traceback (most recent call last):
File "/home/seleniumusername1/selenium1/manage.py", line 8, in <module>
element = browser.find_element_by_xpath("//*[@id='reg_pages_msg']/a")
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 293, in
find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 750, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//*[@id='reg_pages_msg']/a"}
Thanks for your help!