Python selenium automation Linkedin post
12:53 23 Apr 2021

I want to try to automate posting on LinkedIn with selenium. My code works fine until I arrive to the post section. I tried many options x_path, class_name but I get stuck. The message is not written.

I am not sure if I have to use send_keys. I have seen a tuto on youtube similar but with Facebook. Unfortunately, I couldn't adapt it on Linkedin.

If someone has got an idea. I am a complete beginner with selenium and I have some basis of python

Thx

from selenium import webdriver
from getpass import getpass
import time


driver = webdriver.Chrome()
driver.get('https://www.linkedin.com/')

#enter mail
time.sleep(1)
email_box = driver.find_element_by_xpath('//*[@id="session_key"]')
email_box.send_keys('email')

#enter password
time.sleep(1)
password = driver.find_element_by_xpath('//*[@id="session_password"]')
password.send_keys('password')

#checkbox I accept

searchButton = driver.find_element_by_xpath('//*[@id="main- 
content"]/section[1]/div[2]/form/button')
searchButton.click()

#checkbox taf no

#searchBox = driver.find_element_by_xpath('//*[@id="ember48"]')
#searchBox.click()

#chekbox post
box_post = driver.find_element_by_xpath('//*[@id="main"]/div[1]/div/div[1]/button')
box_post.click()
time.sleep(2)

#post boite check
#post_area = driver.find_element_by_xpath('//*[@id="ember404"]/div[2]/div/div/div[1]')
#post_area.click()

#add post 

postarea = driver.find_element_by_xpath('//*[@id="ember395"]/div[2]/div/div/div[1]/p')
postarea.click()
time.sleep(2)
activepostarea=driver.switch_to_active_element()
postarea.send_keys("La nouvelle mise à jour")
#activepostarea=driver.switch_to_active_element()
#activepostarea("La nouvelle mise à jour")

#envoyer le post
time.sleep(2)

button_post = driver.find_element_by_xpath('//*[@id="ember705"]')
button_post.click()
python selenium