0
class Locators:
    def locators(self):
        driver = webdriver.Chrome("C:\\seldriver\\chromedriver.exe")
        driver.get("http://automationpractice.com/index.php")
        driver.maximize_window()
        driver.find_element(By.ID("search_query_top" )).send_keys("T-shirts")
        driver.find_element(By.NAME("submit_search")).click()

i am getting this error while trying to locate an element by simple ID in python-selenium

error

Traceback (most recent call last):
  File "C:/Users/abdul_saboor/PycharmProjects/nopcommerceApp/.pytest_cache/locatorsdemo1.py", line 25, in <module>
    obj_Locators.locators()
  File "C:/Users/abdul_saboor/PycharmProjects/nopcommerceApp/.pytest_cache/locatorsdemo1.py", line 18, in locators
    driver.find_element(By.ID("search_query_top" )).send_keys("T-shirts")
TypeError: 'str' object is not callable

1 Answer 1

3
find_element(By.ID("search_query_top" ))

That is incorrect usage. By.ID is not a separate function.

Use this instead:

find_element(By.ID, "search_query_top" )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.