I am trying to find and click with selenium on python a little plus-button but for any reason I a get a TypeError
TypeError: 'str' object is not callable
This is the link https://meshb.nlm.nih.gov/treeView and I try to find and click the following codesnippet from the html.
<i id="plus_Anatomy" onclick="openTree(this)" ></i>
This is my python code so far. At first it looks like everything should work. So browser windows opens and the webpage is loaded, but then I get this error mentioned above.
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)
The bigger goal is to click on all the buttons and scrap the complete html in the end. can anybody please help me? What am I doing wrong?
CodePudding user response:
You have a syntax error.
Instead of
plus = driver.find_element(By.CLASS_NAME('fakeLink'))
Try
plus = driver.find_element(By.CLASS_NAME, 'fakeLink')
Or even
driver.find_element(By.CLASS_NAME, 'fakeLink').click()