from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC import time url= 'http://www.imooc.com' user_name = '13522919192' password = 'liying0815' driver=webdriver.Chrome() driver.get(url) driver.maximize_window() driver.find_element_by_id('js-signin-btn').click() time.sleep(2) time.sleep(3) driver.find_element_by_name('email').send_keys(user_name) driver.find_element_by_name('password').send_keys(password) driver.find_element_by_class_name('moco-btn').click() time.sleep(3) driver.find_element_by_link_text("猿问").click() time.sleep(2) """ 提问 """ ''' #1 NG invalid selector: Compound class names not permitted #driver.find_element_by_class_name("moco-btn moco-btn-green").click() #que-btn clearfix r #2 ok driver.find_element_by_class_name("moco-btn moco-btn-green").click() t1 =driver.find_element_by_class_name("que-btn") t1.find_element_by_class_name("moco-btn").click() #3 OK driver.find_element_by_xpath('//a[@class="moco-btn moco-btn-green"]') #4 OK driver.find_element_by_css_selector("a.moco-btn").click() ''' #5 driver.find_element_by_link_text("提问").click() time.sleep(2) driver.close() print("You are ")
慕斯4360584
慕斯4360584
慕慕5436299
qq_fly_5