Jan-04-2020, 12:07 PM
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 !!
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')