1

My goal is to be able to open and navigate a web page based on the inputs I enter in Python.

Currently I am having issues inserting a string input into "Street #" field, and keep getting the below error:

AttributeError: 'list' object has no attribute 'send_key'

Text Fields

Here is my code:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary(r"C:...\firefox.exe")

# Open a Web Browser
browser = webdriver.Firefox(firefox_binary = binary)

# Open the 1st Page
browser.get("http://sftreasurer.org/property-tax-payments")
elem_1stClick = browser.find_element_by_css_selector(".ttx_button > div:nth-child(1)")
elem_1stClick.click() # Click on it

# On the 2nd Page
elem_streetNumber = browser.find_elements_by_css_selector("#ContentPlaceHolder1_tbStreetNumber")
elem_streetNumber.send_key("1230")
elem_2ndClick = browser.find_element_by_css_selector("#ContentPlaceHolder1_btnSearch")
elem_2ndClick()

Can anyone help me solve this issue? Your help would be greatly appreciated.

1 Answer 1

1

You should replace this line

elem_streetNumber = browser.find_elements_by_css_selector("#ContentPlaceHolder1_tbStreetNumber")

with this

elem_streetNumber = browser.find_element_by_css_selector("#ContentPlaceHolder1_tbStreetNumber")

This is because find_elements_by_css_selector() returns list of web-elements while find_element_by_css_selector() returns just a single web-element

Sign up to request clarification or add additional context in comments.

2 Comments

You are correct. Thanks. But when I modify the code, a different error message appears "NoSuchElementException: Message: Unable to locate element: #ContentPlaceHolder1_tbStreetNumber". Should I modify the code according to your suggestion, or open a separate question?
Yes, these 2 issues are not related, so you'd better create new ticket

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.