AttributeError: у объекта «InstagramBot» нет атрибута «логин» - PullRequest
0 голосов
/ 11 января 2020
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time


class InstagramBot:
    def __init__(self, username, password):
        self.username = username
        self.password = password
        self.driver = webdriver.Firefox(executable_path=r'D:\geckodriver-v0.26.0-win64\geckodriver.exe')

        def login(self):
            driver = self.driver
            driver.get('https://www.instagram.com')
            time.sleep(2)
            login_button = driver.find_element_by_xpath("//a[@href='/accounts/login/?source=auth_switcher']")
            login_button.click()
            user_element = driver.find_element_by_xpath("//input[@name='username']")
            user_element.clear()
            user_element.send_keys(self.username)
            password_element = driver.find_element_by_xpath("// input[@name='password']")
            password_element.clear()
            password_element.send_keys(self.password)

eduBot = InstagramBot('loginUsername','PasswordSeverals')
eduBot.login()
...