I am trying to automate posting into my social media account. I have successfully written the script to log in, after login in I am having difficulty locating the textarea element with which to pass my post, after which I will try to attach an image to my post, make the post and log out. But for now, I am stuck at the locating the textarea after login in. This is the code
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'JonJames3872@gmail.com'
passwordStr = 'JamesJon'
textStr = 'Testing my Post'
browser = webdriver.Chrome()
browser.get(('https://accounts.kingsch.at/?client_id=com.kingschat&scopes=%5B%22kingschat%22%5D&redirect_uri=https%3A%2F%2Fweb.kingsch.at%2F'))
# fill in username and password
password = browser.find_element_by_name('password')
password.send_keys(passwordStr)
username = browser.find_element_by_class_name('field')
username.send_keys(usernameStr)
signInButton = browser.find_element_by_class_name('submit-btn')
signInButton.click()
# I HAVE LOGGED IN, NOW THIS IS WHERE MY CODE HAS A PROBLEM
text = browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div/div[2]/div/div[1]/div/div/div[1]/textarea")
text.send_keys(textStr)
This is the element, from inspect element:
<textarea placeholder="What's happening?" class="KingingBox__input"></textarea>
- URL: https://accounts.kingsch.at/?client_id=com.kingschat&scopes=%5B%22kingschat%22%5D&redirect_uri=https%3A%2F%2Fweb.kingsch.at%2F
- Sample User name: JonJames3872@gmail.com (strangely here username is case sensitive)
- Sample password: JamesJon