S
S
swpavlov2020-03-18 13:15:37
Python
swpavlov, 2020-03-18 13:15:37

Need help with classes in python?

Need help with classes in python. Below is the code, how to run it?) What should be entered in main?

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.wait import WebDriverWait

URI = "https://www.easports.com/fifa/ultimate-team/web-app/"

class AuthEA(object):
    def __init__(self, browser):
        self.browser = browser

    def press_login(self):
        """"Нажатие кнопки Логин для перекода к оеун авторизации"""
        try:
            self.browser = webdriver.Chrome()
            self.browser.get(URI)
            self.log_button = WebDriverWait(self.browser, 20).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="Login"]/div/div/button[1]')))
            self.log_button.click()
            self.auth_in_EA()
        except:
            print("An exception occurred")

    def auth_in_EA(self):
        """"Авторизация в EA"""
        self.email_auth = self.browser.find_element_by_xpath('//*[@id="email"]')
        self.pass_auth = self.browser.find_element_by_xpath('//*[@id="password"]')
        self.email_auth.send_keys(input("Введите E-mail: "))
        self.pass_auth.send_keys(input("Введите пароль: "))
        self.log_in = self.browser.find_element_by_xpath('//*[@id="btnLogin"]')
        self.log_in.click()
        try:
            self.text_wrong_pass = self.browser.find_element(By.XPATH, '//*[@id="loginForm"]/div[1]/div/div')
            print('Неправильный пароль или логин попробуй еще раз')
            self.pass_auth.send_keys(input("Введите пароль: "))
            self.log_in.click()
        except NoSuchElementException:
            print("Элемент не найден")
        self.verific_send_code()

    def verific_send_code(self):
        """"Подтверждение ключа активации"""
        try:
            self.verific_code = self.browser.find_element(By.XPATH, '//*[@id="btnSendCode"]')
            print("Жду код активации")
            self.verific_code.click()
            self.verific_send_code()
        except NoSuchElementException:
            print("Код не найден")



def main():
    pass



if __name__ == "__main__":
    main()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-03-18
@bacon

Open the docks or a book and read about classes in python.
PS Woodpeckers incapable of learning got it, they also put complexity on elementary questions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question