硒常见异常:超时异常消息如何纠正

时间:2020-05-14 10:39:54

标签: python selenium selenium-webdriver selenium-chromedriver browser-automation

from selenium.webdriver.common.by import By 
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup as b
import time

class Login:
    def __init__(self, driver, username, password):
        self.driver = driver
        self.username = username
        self.password = password
    def signin(self):
        print('opening')
        self.driver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
        uid = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(2) > div > label > input')))
        uid.click()
        uid.send_keys(self.username)
        pswd = self.driver.find_elements_by_css_selector('#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(3) > div > label > input')
        pswd.click()
        pswd.send_keys(self.password)
        btn = self.driver.find_elements_by_css_selector('#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(4)')
        btn.click()
        time.sleep(3)

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

模块'selenium.webdriver.support.expected_conditions'没有'presence_of_elements_located'成员;也许是“ presence_of_element_located”?

Date().nextHalfHour // "May 23, 2020 at 1:00 AM"