各位大神,向大家请教个问题。
用python的selenium下一个百度登陆的脚本
from selenium import webdriver
import time as t
browser = webdriver.Chrome()
browser.get('http://www.baidu.com')
t.sleep(3)
load_css = 'html body div#wrapper div#head div.head_wrapper div#u1 a.lb'
load_name = 'tj_login'
#为什么这里用name找不到元素
load_xpath = '/html/body/div[4]/div[1]/div/div[3]/a[7]'
browser.find_element_by_css_selector(load_css).click()
name_css = 'html body div#passport-login-pop.tang-pass-pop-login-noimg.tang-pass-pop-login-merge.tang-pass-pop-login-tpl-mn.tang-pass-pop-login-color-blue.tang-pass-pop-login div#TANGRAM__PSP_2__foreground.tang-foreground div#TANGRAM__PSP_2__body.tang-body div#TANGRAM__PSP_2__content.tang-content div#passport-login-pop-dialog div.clearfix div.pass-login-pop-content div.pass-login-pop-form div#passport-login-pop-api.tang-pass-login form#TANGRAM__PSP_8__form.pass-form.pass-form-normal p#TANGRAM__PSP_8__userNameWrapper.pass-form-item.pass-form-item-userName input#TANGRAM__PSP_8__userName.pass-text-input.pass-text-input-userName'
name_id = 'TANGRAM__PSP_8__userName'
name_xpath = '//*[@id="TANGRAM__PSP_8__userName"]'
#这里用三种方式都找不到用户名输入框的元素?
browser.find_element_by_css_selector(css).click()
browser.find_element_by_css_selector(css).claer()
用python的selenium下一个百度登陆的脚本
from selenium import webdriver
import time as t
browser = webdriver.Chrome()
browser.get('http://www.baidu.com')
t.sleep(3)
load_css = 'html body div#wrapper div#head div.head_wrapper div#u1 a.lb'
load_name = 'tj_login'
#为什么这里用name找不到元素
load_xpath = '/html/body/div[4]/div[1]/div/div[3]/a[7]'
browser.find_element_by_css_selector(load_css).click()
name_css = 'html body div#passport-login-pop.tang-pass-pop-login-noimg.tang-pass-pop-login-merge.tang-pass-pop-login-tpl-mn.tang-pass-pop-login-color-blue.tang-pass-pop-login div#TANGRAM__PSP_2__foreground.tang-foreground div#TANGRAM__PSP_2__body.tang-body div#TANGRAM__PSP_2__content.tang-content div#passport-login-pop-dialog div.clearfix div.pass-login-pop-content div.pass-login-pop-form div#passport-login-pop-api.tang-pass-login form#TANGRAM__PSP_8__form.pass-form.pass-form-normal p#TANGRAM__PSP_8__userNameWrapper.pass-form-item.pass-form-item-userName input#TANGRAM__PSP_8__userName.pass-text-input.pass-text-input-userName'
name_id = 'TANGRAM__PSP_8__userName'
name_xpath = '//*[@id="TANGRAM__PSP_8__userName"]'
#这里用三种方式都找不到用户名输入框的元素?
browser.find_element_by_css_selector(css).click()
browser.find_element_by_css_selector(css).claer()