WebDriverException:消息:类型错误:矩形未定义 [英] WebDriverException: Message: TypeError: rect is undefined

查看:43
本文介绍了WebDriverException:消息:类型错误:矩形未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 selenium 从带有 python 脚本的网站自动下载数据,但出现以下错误:

I am trying to automate the download of data from a website with a python script using selenium but I get the following error:

"WebDriverException: Message: TypeError: rect is undefined".

代码试用:

from selenium import webdriver
from selenium.webdriver.common import action_chains

driver = webdriver.Firefox()
url="https://www.hlnug.de/?id=9231&view=messwerte&detail=download&station=609"
driver.get(url)

现在我定义要单击的复选框并尝试单击它:

Now I define the check-box I want to click and I try to click on it:

temp=driver.find_element_by_xpath('//input[@value="TEMP"]')
action = action_chains.ActionChains(driver)

action.move_to_element(temp)
action.click()
action.perform()

我已经在网上搜索了 2 个小时,但没有任何成功.因此,欢迎提出任何想法!

I already searched 2 hours on the net without any success. Any idea is therefore welcome!

非常感谢!

推荐答案

有两个元素与该定位符匹配.第一个不可见,所以我假设您想点击第二个.

There are two elements that match that locator. The first one is not visible so I'm assuming you want to click on the second.

temp = driver.find_elements_by_xpath('//input[@value="TEMP"]')[1] # get the second element in collection
action = action_chains.ActionChains(driver)

action.move_to_element(temp)
action.click()
action.perform()

这篇关于WebDriverException:消息:类型错误:矩形未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆