Panna Lal Patodia
1 min readSep 10, 2022

--

We have entered the following description:

login to Facebook and post "This is excellent story" as response to the post of story by X.

and selected the Python language.

The following code was generated. Please check:

------------------------------------------------------------

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

import time

# Replace below path with the absolute path

# to chromedriver in your computer

driver = webdriver.Chrome('/home/saurabh/Downloads/chromedriver')

driver.get("https://www.facebook.com/")

assert "Facebook" in driver.title

elem = driver.find_element_by_id("email")

elem.send_keys("saurabh.kumar@gmail.com")

elem = driver.find_element_by_id("pass")

elem.send_keys("password")

elem.send_keys(Keys.RETURN)

# Replace 'story_fbid' with the story fbid value

# you want to comment on

driver.get("https://www.facebook.com/story_fbid=1234567890123456&id=1234567890123456")

# Replace '1234567890123456' with the comment box

# element ID of the story

wait = WebDriverWait(driver, 10)

comment_box = wait.until(EC.presence_of_element_located((By.ID, "1234567890123456")))

comment_box.click()

comment_box.send_keys('This is excellent story')

# Replace '1234567890123456' with the comment

# button element ID of the story

wait = WebDriverWait(driver, 10)

comment_button = wait.until(EC.presence_of_element_located((By.ID, "1234567890123456")))

comment_button.click()

time.sleep(5)

driver.close()

------------------------------------------------------------

--

--

Panna Lal Patodia
Panna Lal Patodia

Written by Panna Lal Patodia

CEO of Patodia Infotech Private Limited.

No responses yet