Program: Python + Selenium
Situation: I am trying to run a script to automate Facebook login and open my Facebook home page
Problem: I am a beginner and i am not sure if there is a problem in my python configuration or i am just doing a code mistake. the code is stopping at the last line. How did I retrieve the element class? i went to Facebook page and i inspected the profile button element and i copied it but it is not working (_1vp5 f_click)
Resolution: could you please direct me on the best way to find the home page element
Below is my code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path=r"chromedriver.exe")
driver.get("http://www.facebook.com")
usr = "xxxxx"
pwd = "yyyy"
assert "Facebook" in driver.title
elem = driver.find_element_by_id("email")
elem.send_keys(usr)
elem = driver.find_element_by_id("pass")
elem.send_keys(pwd)
elem.send_keys(Keys.RETURN)
driver.find_element_by_class("_1vp5 f_click").click()
Code output:
Traceback (most recent call last):
File "C:/Users/shouks/MyPythonScripts/test1.py", line 23, in <module>
driver.find_element_by_class("_1vp5 f_click").click()
AttributeError: 'WebDriver' object has no attribute 'find_element_by_class'