Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fix error upload image in python
#1
i have problem uploading images in selenium code for instagram auto post..

upload = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH ,'//*[@id="react-root"]/section/nav[2]/div/div/div[2]/div/div/div[3]/span'))).click()

upload.send_keys('C:/Users/abdlwafitahiri/Desktop/Python/INSTAGRAM%20AUTO%20POSt/dm%20cover.png')


i'm write path img in send_keys .. But it does not work !!


from selenium import webdriver
from selenium.webdriver.chrome.options import Options
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

image = 'C:/Users/abdlwafitahiri/Desktop/Python/INSTAGRAM%20AUTO%20POST/dm%20cover.png'
text = 'This will be the caption of your photo.' + '\r\n' + 'You can also use hashtags! #hash #tag #now " PYTHON TEST"'

chrome_options = Options()
chrome_options.add_argument('--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1')
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://www.instagram.com/accounts/login/')

user = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH ,'//*[@id="react-root"]/section/main/article/div/div/div/form/div[4]/div/label/input')))
user.send_keys('username')
passwd = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="react-root"]/section/main/article/div/div/div/form/div[5]/div/label/input')))
passwd.send_keys('password')
login = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH ,'//*[@id="react-root"]/section/main/article/div/div/div/form/div[7]/button'))).click()
plustard = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH ,'//*[@id="react-root"]/section/main/div/button'))).click()
annulerbtn = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH ,'/html/body/div[4]/div/div/div[3]/button[2]'))).click()
upload = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH ,'//*[@id="react-root"]/section/nav[2]/div/div/div[2]/div/div/div[3]/span'))).click()
upload.send_keys('file:///C:/Users/abdlwafitahiri/Desktop/Python/INSTAGRAM%20AUTO%20POSt/dm%20cover.png')
Reply
#2
please show complete unaltered error traceback (in error tags) it contains important debugging information
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  upload big file in Django with process bar and i get error : MemoryError ma_norouzifar 3 4,336 Aug-06-2019, 06:57 AM
Last Post: fishhook
  python largesize(6GB) file upload fails nithya_g 2 4,094 Jan-29-2018, 09:11 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020