selenium如何给隐藏输入框发送keys?
澳门新葡京官网
澳门新葡京官网
当前位置 : 澳门新葡京官网 > 澳门新葡京官网

selenium如何给隐藏输入框发送keys?

<span class="table_n_abs" onclick="hideNameInput" id="nameNoteId" style="top: 10px; font-size: 14px; font-family: 微软雅黑; display: block;">邮箱/手机号/帐号</span>
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

import time
url = http://passport2.chaoxing.com/login?fid=1479&refer=http://i.mooc.chaoxing.com
# driver = webdriver.PhantomJS
driver = webdriver.Firefox
driver.geturl
time.sleep1
elem = driver.find_element_by_idpasswordId
elem.send_keysCNM
not_work_elem = driver.find_element_by_idnameNoteId
not_work_elem.click
not_work_elem.send_keystest

time.sleep10
driver.close
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

url = http://passport2.chaoxing.com/login?fid=1479&refer=http://i.mooc.chaoxing.com

driver = webdriver.Firefox
driver.geturl

wait = WebDriverWaitdriver, 10

span = wait.untilEC.visibility_of_element_locatedBy.ID, "nameNoteId"
span.click

unameId = wait.untilEC.visibility_of_element_locatedBy.ID, "unameId"
unameId.send_keysa

passwordId = wait.untilEC.visibility_of_element_locatedBy.ID, "passwordId"
passwordId.send_keysb

一个思路,用selenium的executeScript执行javascript脚本触发隐藏输入框显示,然后再切换到输入框完成输入。

栏目列表

广告位

澳门新葡京官网