Answer the question
In order to leave comments, you need to log in
What's wrong with my Python OOP?
I've been writing an Instagram bot for some time now using the Selenium framework. Recently, I decided to move most of the code into a class so that everything is correct and orthodox, and it was already neatly sorted into functions, and the functions themselves were stuffed into the class. I felt a sharp pain somewhere in my chest.
Here is a small snippet from the main code that will clearly demonstrate the essence of the problem:
from data import login, password #данные аккаунта, которые программа вводит при авторизации
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
class Newbie():
def __init__(self, login, password):
self.login = login
self.password = password
self.driver = webdriver.Firefox()
def logging(self, login, password):
driver = self.driver
try:
driver.get("https://www.instagram.com")
time.sleep(5)
login_input = driver.find_element_by_name("username")
login_input.clear()
login_input.send_keys(login)
time.sleep(5)
password_input = driver.find_element_by_name("password")
password_input.clear()
password_input.send_keys(password)
password_input.send_keys(Keys.ENTER)
time.sleep(5)
except Exception as ex:
print(ex)
self.killdriver() #функция которая закрывает браузер
Newbie.logging(login, password)
TypeError: logging() missing 1 required positional argument: 'password'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question