driver.find_elements_by_css_selector("input[placeholder='from']").send_keys("del") AttributeError: 'list' object has no attribute 'send_keys'

0 votes
from selenium import webdriver

driver = webdriver.Chrome(executable_path="c:\\chromedriver.exe")
driver.get("https://www.makemytrip.com/")
driver.find_element_by_id("fromCity").click()
driver.find_elements_by_css_selector("input[placeholder='from']").send_keys("del")
cities = driver.find_elements_by_css_selector("p[class*='blacktext']")
for city in cities:
    if city.text == "Del Rio, United States":

This is my code. I am getting error as

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

May 20 in Python by Nupur
• 120 points

edited May 20 by Gitika 48 views

1 answer to this question.

0 votes

Hey, @Nupur,

You are getting a list of web elements with

driver.find_elements_by_css_selector("input[placeholder='from']").send_keys("del")
cities = driver.find_elements_by_css_selector("p[class*='blacktext']")

instead of that use this

driver.find_element_by_css_selector("input[placeholder='from']").send_keys("del")
cities = driver.find_element_by_css_selector("p[class*='blacktext']")

I hope this will help.

answered May 20 by Gitika
• 29,690 points

Related Questions In Python

0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,540 points
3,070 views
0 votes
1 answer
0 votes
1 answer

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

There is no attribute called “rows”. The ...READ MORE

answered Mar 28, 2019 in Python by Shri
28,792 views
0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

answered Jun 19, 2019 in Python by Faiza
987 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 963 views
0 votes
0 answers
0 votes
1 answer

AttributeError: type object 'DataFrame' has no attribute 'from_items'

Hi, @Bronson, You can go through this, I ...READ MORE

answered Apr 6 in Python by Gitika
• 29,690 points
435 views
0 votes
1 answer