Mladen MODD
Mladen MODD

Reputation: 31

Trying to select element inside webelement, but i get object is not callable error

I have been trying to select element inside of web element, and i get: "TypeError: 'WebElement' object is not callable"

def get_engagmet(driver, time, a):
    engagment = {}
    body_element = driver.find_elements_by_xpath("//div[@class='_5pcr userContentWrapper']")
    link = body_element[a].find_element_by_xpath(".//a[@rel='theater']")
    print("this is link")
    print(link("href"))
    time.sleep(3)

By all accounts this should work.

Upvotes: 0

Views: 112

Answers (1)

Alejandro Lorefice
Alejandro Lorefice

Reputation: 891

Replace

print(link("href"))

with

print(link.get_attribute("href"))

P.S. Also you might share the URL you are trying to scrape to check if your XPath matches correctly.

Upvotes: 1

Related Questions