0
0 комментариев

Версия Python 3.8.1

Windows 10 x64

from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
import time

useraname = '...'
chromedriver = 'E:/python/Scripts/chromedriver'
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(executable_path="E:/python/Scripts/chromedriver", options=options)
driver.set_window_size(1120, 550)

def loggi():
    driver.get('https://www.nike.com/ru/login')
    time.sleep(1)
    email = driver.find_element_by_name('emailAddress')
    password = driver.find_element_by_name('password')
    loginButton = driver.find_element_by_xpath("//input[@type='button']")
    useraname1 = useraname
    email.send_keys(useraname1)
    time.sleep(8)
    password.send_keys('password')
    time.sleep(8)
    loginButton.click()
    time.sleep(6)
    if driver.find_element_by_link_text('ОШИБКА'):
        print(Ошибка входа)
        loggi()
    else:
        print(Успешный вход)

loggi()

Traceback (most recent call last):
File «C:/Parsing/Nike.py», line 47, in <module>
loggi()
File «C:/Parsing/Nike.py», line 41, in loggi
if driver.find_element_by_link_text(‘ОШИБКА’):
File «C:\Parsing\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py», line 428, in find_element_by_link_text
return self.find_element(by=By.LINK_TEXT, value=link_text)
File «C:\Parsing\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py», line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File «C:\Parsing\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py», line 321, in execute
self.error_handler.check_response(response)
File «C:\Parsing\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py», line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {«method»:»link text»,»selector»:»ОШИБКА»}
(Session info: chrome=79.0.3945.130)


Добавить комментарий