squidg
squidg

Reputation: 581

Python3 Whatsapp + Selenium - "Click" Object not callable

I'm having trouble clicking on people's names within 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::*')

Upvotes: 0

Views: 90

Answers (1)

C. Peck
C. Peck

Reputation: 3717

The syntax click() won't work because click is a webElement, not a function. It should be like

element = driver.find_element_by_xpath(f'//span[contains(@title,"{person}")]')
element.click()

Upvotes: 2

Related Questions