我正在尝试使用selenium自动输入http://ueditor.baidu.com/website/examples/completeDemo.html中的HTML代码。我的程序是先单击html,然后编写html代码,而IDE总是告诉我找不到元素。在点击HTML Button之后,元素是正确的there,但总是出错,这让我抓狂。我只是想知道我怎么能写在框后,点击HTML按钮使用硒?多亏了那个热心人
import os,time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
chromePath = r'E:/Python/WEB/web-infor-transfer/monidenglu/chromedriver.exe'
wd = webdriver.Chrome()
loginUrl = 'http://ueditor.baidu.com/website/examples/completeDemo.html'
wd.get(loginUrl)
wd.find_element_by_xpath('//*[@id="edui4"]').click()
time.sleep(2)
wd.find_element_by_xpath('//*[@id="edui1_iframeholder"]/div/div[2]/div/div/div[2]/div/div[2]').send_keys('hello')
time.sleep(5)
wd.quit()
试试动作链。例如,将密钥发送到浏览器本身就起作用:
相关问题 更多 >
编程相关推荐