不能点击按钮|关于WordPress Python 2.7的Selenium

时间:2017-08-31 00:12:41

标签: python wordpress selenium selenium-webdriver selenium-chromedriver

我正在使用Selenium Web Driver和Python, 由于某种原因,有一个我无法点击的按钮。

该按钮是WordPress文件上传的浏览按钮。

我已经使用AutoIT编写了一个脚本来处理文件对话框,所以我只需要点击一个HTML按钮来启动对话框,然后从那里 os.startfile(script.exe)做其余的事。

这是我的代码:

print 'find button'
browseButton = driver.find_element_by_css_selector('#plupload-browse-button')
browseButton.click()
time.sleep(5)
print "AutoIT runs here"

错误:

Error: Message: no such element: Unable to locate element

(完全见于附图)

P.S:代码确实存在,它在崩溃之前打印了这条线,我甚至在它到达崩溃线之前延迟了30秒,所以一切都会加载200%。 请帮忙=) enter image description here 最好的问候,提前感谢大家 -CodingCode。

1 个答案:

答案 0 :(得分:0)

可能会有一些事情,有些已在评论中提及,所以不在此重复。

但是如果它不在框架内并且xpath是正确的。你可以使用显式等待。

wait = WebDriverWait(driver, 30) 
elem = wait.until(EC.presence_of_element_located((By.ID, 'plupload-browse-button')))
elem.click()