0

I am new in Selenium, and now learning how to access the elements of a webpage and pass the value in the available elements. For more fun, I want to login on to my Facebook page automatically and then post a random post in my account. But the problem is, as Selenium is running the Chrome browser on Private/Guest mode so I need to log in every time on Facebook, but what I want is: I will log in to my Facebook profile only once, and the rest of the time (or some specific time), I don't need to login (which is a common case on the normal mode of a browser). I have no idea whether or how to run Selenium in normal mode. Here is my code:

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


os.chmod("D:/python/selenium/driver/chromedriver.exe", 0o755)
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)

driver = webdriver.Chrome("D:/python/selenium/driver/chromedriver.exe", chrome_options=chrome_options)
from_url = "https://www.facebook.com/"
driver.get(from_url)
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'email')))
driver.find_element_by_id('email').send_keys("my_facebook_username")
driver.find_element_by_id('pass').send_keys("my_facebook_password")
driver.find_element_by_name('login').click()
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'email')))
# write code to access the post POP Up and write a random post

Can anyone help to figure out what I need to change on my code so that Selenium opens the Chrome browser in normal mode rather than Private/Guest mode?

N.B: I know Facebook provides API to perform what I want to achieve, but I just want to learn, nothing for permanent use.

  • Thanks
Shimul
  • 5
  • 2
  • 1
    Already answered here : https://stackoverflow.com/questions/31062789/how-to-load-default-profile-in-chrome-using-python-selenium-webdriver – Rakesh Poddar Nov 13 '21 at 12:05

0 Answers0