【发布时间】:2019-10-30 05:11:46
【问题描述】:
我不知道如何单击此按钮。它具有图像和文本等标识符,但我不确定如何使用它们来发挥我的优势。
我尝试过使用 XPATH,我尝试过使用文本,我尝试过使用图片的链接,但我无法让它正常工作
我的代码:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Continue Watching"))).click()
按钮 HTML:
<button style="margin-top: 15px;
width: 240px;
height: 46px;
background-color: #69b8d6;
margin: 50px auto;
border-radius: 4px;
color: white;
display: block;
margin-left: 159px;
font-size: 16px;"><img style="padding-right:15px;" src="http://img.encrave.tv/global/watchCamcorder.png">Continue Watching</button>
如果这个按钮 html 变成一个实际的按钮,我很抱歉,我不确定如何处理。
我的预期结果是“查找并等待按钮可点击”。然后单击它。我的实际结果是什么都没有发生,并且在控制台中弹出一个错误。
raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', 端口 = 49951):最大重试次数超出了 url: /session/4100d1e939db4a44f287a50f5e9be234/element(由 NewConnectionError(': 建立新连接失败: [WinError 10061] 否 可以建立连接,因为目标机器主动拒绝 它'))
【问题讨论】:
标签: python selenium xpath css-selectors webdriverwait