Selenium: TypeError: 'str' object is not callable

Question:

Is there anyone can help me?

I want to track live stock price, using Selenium.

That’s my code:

#https://www.youtube.com/watch?v=CtCeuJaRgLQ&t=16s&ab_channel=G%C3%BCneyBircan

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.maximize_window()
driver.delete_all_cookies()
driver.get("https://finans.mynet.com/borsa/hisseler/asels-aselsan/")
driver.implicitly_wait(5)

price_info = driver.find_element(By.XPATH('/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div'))

    

Exception:

price_info = driver.find_element(By.XPATH('/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div')) TypeError: 'str' object is not callable PS C:UsersLenovoDesktopAkademiAlgoTradingyfinance>

Asked By: Baris

||

Answers:

Use
price_info = driver.find_element(By.XPATH, '/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div')

Instead of
price_info = driver.find_element(By.XPATH('/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div'))

Answered By: EL-AJI Oussama
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.