python-3.x - Python3 Whatsapp + Selenium - “点击”对象不可调用
问题描述
我无法在 whatsapp 中点击人名。
The error is:
TypeError: 'WebElement' object is not callable
.
My code:
person = 'Tom'
click = driver.find_element_by_xpath(f'//span[contains(@title,"{person}")]')
click()
I also tried
click = driver.find_element_by_xpath(f'//span[contains(@title,"{person}")]/parent::*')
解决方案
该语法click()
不起作用,因为click
它是一个 webElement,而不是一个函数。它应该像
element = driver.find_element_by_xpath(f'//span[contains(@title,"{person}")]')
element.click()
推荐阅读
- python - Python:识别按下了哪些键,处理所有按下的键,然后打印结果
- ocaml - OCaml 中的语法:修改后传递数组
- python - Python Pytest 解压夹具
- python-3.x - Tensorflow 和 Keras 中的相同(?)神经网络架构在相同数据上产生不同的准确性
- jquery - Html 不呈现 Jquery 中的附加元素
- bigcommerce - 如何在 Bigcommerce 中获取路径图像?
- shell - Shell 脚本 - 将 .csv 文件中的分隔符从逗号更改为管道
- aem - 如何允许将某些组件添加到 AEM Experience Fragment(使用设计)?
- java - 主类不会自动创建客户端
- c - 如何获取字符串的特定部分?