

Code: Alles auswählen
File "bot.py", line 41, in __init__
upload.send_keys(os.getcwd() + "/File_Manager/fin4.jpg")
AttributeError: 'NoneType' object has no attribute 'send_keys'
Hier ist der komplette Code:
Code: Alles auswählen
from time import sleep
from selenium import webdriver
import os
class InstBot():
def __init__(self,username, pw):
self.username = username
self.pw = pw
mobile_emulation = {"deviceName": "Nexus 5"}
options = webdriver.ChromeOptions()
options.add_experimental_option("mobileEmulation", mobile_emulation)
self.driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', options=options)
self.driver.get("https://www.instagram.com")
sleep(2)
closeCookie = self.driver.find_element_by_xpath("/html/body/div[1]/section/div[1]/button").click() #Cookie Close
getToLogin = self.driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div/div/div/div[2]/button").click() #Go to Login
sleep(1)
login_field = self.driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div/div/div/form/div[4]/div/label/input")\
.send_keys(username) #Username Field
login_field2 = self.driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div/div/div/form/div[5]/div/label/input")\
.send_keys(pw) #Password Field
self.driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div/div/div/form/div[7]").click() #Login Button
sleep(2)
self.driver.find_element_by_xpath("/html/body/div[1]/section/main/div/div/div/button").click() #Close Pop_Up 1
sleep(1)
self.driver.find_element_by_xpath("/html/body/div[4]/div/div/div[3]/button[2]").click() #Close Pop-Up 2
sleep(1)
upload = self.driver.find_element_by_xpath("/html/body/div[1]/section/nav[2]/div/div/div[2]/div/div/div[3]").click() #Click Upload Button
sleep(1)
upload.send_keys(os.getcwd() + "/File_Manager/fin4.jpg")
print("Bot successful!")
def getUserName(self):
print(self.username)
a = InstBot('testuserpython', 'test12345')
Ich bedanke mich schonmal im voraus für eure Hilfe
