ethanXWL / Python-Selenium-Facebook-group-auto-poster

A Python script use Selenium to achieve automatically posting images with text on multiple Facebook groups that you are member.
52 stars 22 forks source link

id of the login button changes frequently #2

Open omar44g opened 3 years ago

omar44g commented 3 years ago

In this section here

# Login Facebook
    chrome_options = webdriver.ChromeOptions()
    prefs = {"profile.default_content_setting_values.notifications" : 2}
    chrome_options.add_experimental_option("prefs",prefs)
    driver = webdriver.Chrome(chrome_options=chrome_options)
    driver.get('https://www.facebook.com')
    emailelement = driver.find_element(By.XPATH,'//*[@id="email"]')
    emailelement.send_keys(account)
    passelement = driver.find_element(By.XPATH,'//*[@id="pass"]')
    passelement.send_keys(password)
    loginelement = driver.find_element(By.XPATH,'//*[@id="loginbutton"]')
    loginelement.click()

loginelement = driver.find_element(By.XPATH,'//*[@id="loginbutton"]') the id always changes on Facebook and you should change it to the following:

# Login Facebook
    chrome_options = webdriver.ChromeOptions()
    prefs = {"profile.default_content_setting_values.notifications" : 2}
    chrome_options.add_experimental_option("prefs",prefs)
    driver = webdriver.Chrome(chrome_options=chrome_options)
    driver.get('https://www.facebook.com')
    emailelement = driver.find_element(By.XPATH,'//*[@id="email"]')
    emailelement.send_keys(account)
    passelement = driver.find_element(By.XPATH,'//*[@id="pass"]')
    passelement.send_keys(password)
    loginelement = driver.find_element(By.XPATH,'//*[@name="login"]')
    loginelement.click()