【发布时间】:2016-11-03 09:42:02
【问题描述】:
我使用 Python 2.7、Webdriver 和 Chrome 访问 Pinterest 以将图像插入到板。我已成功登录该站点并创建了一个板。我遇到的问题是,当我的代码尝试单击添加 pin 元素时,出现异常。
元素是页面右下角的“+”按钮(见附件“红色箭头”)。我在元素上附加了 Chrome 检查的图像。
我在研究中看到了一个答案,它表明带有 Chrome 的 Webdriver 在某些情况下存在“跨度”问题。请注意,我可以在按钮的任意位置手动单击该元素。
我的代码:----
print "e20 addbutton"
addbutton = driver.find_element_by_xpath("//span[@class='accessibilityText' and contains(text(), 'Save Pin')] ")
print addbutton
if addbutton.is_enabled():
print "addbutton enabled"
if addbutton.is_displayed():
print "addbutton displayed"
addbutton.click()
上面的输出是:----
e20 添加按钮
添加按钮已启用 添加按钮显示
addbutton.click() 出现以下异常:----
raise exception_class(message, screen, stacktrace)
WebDriverException:消息:未知错误:元素不可点击 在点 (871, 845)。其他元素会收到点击: (会话信息:chrome=54.0.2840.71)(驱动程序信息: 铬驱动程序=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),平台=Windows NT 10.0.14393 x86_64)
【问题讨论】:
-
我看不到附件,单独添加。
标签: python-2.7 google-chrome selenium-webdriver