This can be done with extra filtering in Python, but the usual straightforward way is to add an extra condition to your CSS selector:
all_items = driver.find_elements_by_css_selector("ul > li")
filtered_items = driver.find_elements_by_css_selector("ul > li.myclass")
where . is a class selector.
Python has a feature called List Compreenshion, aimed at creating lists from other lists, after applying some processing on each element.
1 - Find the li elements:
li_items = driver.find_elements_by_class_name("li")
2 - Filter in only element with a given class:
li_items_with_class = [ item for item in list_items if "my_class" in item.get_attribute("...
I don't know the exact answer but maybe can help find the solution. Have you tried finding out if this is actually the correct window handle? You could try debugging by:
Counting the number of window handles
Opening the last window handle in stead of exactly 
Reading the DOM of all window handles to see what is found by executing this script over each ...
Did you try to read the documetation for the Selenium Python package? See: https://selenium-python.readthedocs.io/navigating.html
Code example from the documentation:
from selenium.webdriver.support.ui import Select
select = Select(driver.find_element_by_name('name'))
The idea here is to apply the findAll - filter - extract pattern.
ng_scopes = driver.find_elements_by_class("ng-scope")
ng_scopes_with_status_one = [ng_scope for ng_scope in ng_scopes if ng_scopes.find_element_by_css_selector(".col-xs-8 span").text == "1"]
ng-repeat_value = ng_scopes_with_status_one.get_attribute("ng-...
There is an animation when you land the page.
Before using the element, you have to wait for it to be clickable.
element = WebDriverWait(driver, 20).until(
I don't think you need to iterate through them.
Just target the correct element, your xpath could look like this:
One of the problems with your current xpath is you're trying to find an 'a' element, where the fake radio buttons are actually 'li' elements.
You first have to open the menu, by clicking on the From City text, using ID.
Then you can query the autocomplete, but fixing the locator you used (only one class is necessary):
I think by class name only takes a single class not multiple.
You could try a css selector to find elements with two classes:
element = driver.find_element_by_css_selector(".react-autosuggest__input.react-autosuggest__input--open")
Or just only use one of the classes instead of both.
You should try looping over the list you created. z is a list, and when you don't loop over the list it tries to run only once.
for value in z:
driver.find_element_by_xpath("//div[text()='Maximum 5000 Names']/..//textarea").send_keys(value)