执行这个python代码:
from selenium import webdriver
import time
url = "http://125.221.35.78:8080/selfservice/"
browser = webdriver.Firefox()
browser.get(url)
time.sleep(5)
browser.switch_to_frame("entry.jsp")
username_element = browser.find_element_by_id('name_text')
username_element.clear()
username_element.send_keys('2016010387')
time.sleep(2)
password_element = browser.find_element_by_id('password_text')
password_element.clear()
password_element.send_keys('123456')
time.sleep(2)
但是这个Python代码不起作用。因为这两个标签包含javascript代码。 如:
<input tabindex="1" class="loginInputHK" type="text" value="username" id="name_text" onclick="this.className='loginInputHKClicked'" onfocus="this.className='loginInputHKClicked';" onblur="this.className='loginInputHK';" style="display: inline-block;">
<input tabindex="2" class="loginInputHK" type="text" value="password" id="password_text" onclick="this.className='loginInputHKClicked'" onfocus="hidePwdErrorImg()" onblur="this.className='loginInputHK';blurPwdDiv()" style="display: inline-block;">
如何在selenium scrapy中执行此javascript代码?
每个人都可以帮助我吗? 谢谢大家!