我试图在python上查找并点击selenium,一个加号按钮,但是由于任何原因,我得到了一个TypeError。
TypeError: 'str' object is not callable这是https://meshb.nlm.nih.gov/treeView的链接,我尝试从html中找到并单击以下代码。
<i id="plus_Anatomy" onclick="openTree(this)" class="fa fa-plus-circle treeCollapseExpand fakeLink"></i>到目前为止,这是我的python代码。一开始看起来一切都正常。所以浏览器窗口打开,网页被加载,但是我得到了上面提到的错误。
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://meshb.nlm.nih.gov/treeView")
plus = driver.find_element(By.CLASS_NAME('fakeLink'))
driver.execute_script("arguments[0].click();", plus)更大的目标是点击所有的按钮,最后销毁完整的html。有人能帮帮我吗?我做错了什么?
发布于 2022-09-28 20:13:25
您有语法错误。
而不是
plus = driver.find_element(By.CLASS_NAME('fakeLink'))试一试
plus = driver.find_element(By.CLASS_NAME, 'fakeLink')甚至
driver.find_element(By.CLASS_NAME, 'fakeLink').click()https://stackoverflow.com/questions/73887267
复制相似问题