Home python Error “'str' object is not callable” when trying to find an element...

Error “’str’ object is not callable” when trying to find an element on the page

Author

Date

Category

I have the following code:

el = browser.find_element(By.CSS_SELECTOR('div.iconTabSheet95_0.PPTSPicture')) 

When I try to run it, I get the following error:

File "C:\Users\belkina\source\repos\try_ros\try_ros\try.py", line 25, in <module>
    el = browser.find_element(By.CSS_SELECTOR('div.iconTabSheet95_0.PPTSPicture'))
TypeError: 'str' object is not callable

When I try to search for an element on a page using a selector, I find it:
enter image description here

Why isn’t my code working?


Answer 1, authority 100%

Change the line:

el = browser.find_element(By.CSS_SELECTOR('div.iconTabSheet95_0.PPTSPicture')) 

To:

el = browser.find_element_by_css_selector('div.iconTabSheet95_0.PPTSPicture')

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions