I am trying to fill up an autocomplete zipcode / town form. Even if you input the whole zipcode / town in once you still must validate the autocomplete search (just under the input).I do not put the whole error messages for each attempt otherwise my post would be too long (I put a number for each attempt and --> to show the corresponding result).
the input:
ville = 31000 Toulouse
geo = driver.find_element_by_id("location_p")
geo.send_keys(ville)
from here starts the issue: Here is the line making pbs:
<li data-region="16" data-dpt-code="31" class="selected">
<span class="city" title="Toulouse">Toulouse</span>
<span class="zipcode">31000</span>
</li>
1.
validate = driver.find_element_by_xpath("//li[@class='selected'][contains(.,'data-dpt-code')]")
validate.click()
--> unable to locate element
2.
validate = driver.find_element_by_css_selector("li.selected")
validate.click()
--> <exception str() failed>
but
validate = driver.find_element_by_css_selector("li.selected")
assertTrue(validate_is_displayed() and validate_is_enabled())
validate.click()
-> unable to locate element
3. from this : How to handle autocomplete list in webdriver?, I tried:
geo.send_keys(Keys.TAB)
geo.send_keys(Keys.TAB)
geo.send_keys(Keys.DOWN)
-> no error, but the zipcode / town is not validated
4.from Selenium Python - select from autosuggest dropdown, tried
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@class='selected']/span[@class='city][contains(.,'Toulouse')]"
-> idem as 3
5.from Selenium in Python How use a If - else code if an element is not present, I tried:
elem = driver.find_element_by_xpath('//*[@class="selected"][contains(.,"data-dpt-code")]')
valid = driver.find_element_by_xpath('//span[@class="city"][contains(.,"Toulouse")]')
if valid.is_displayed():
elem.click()
-> selenium.common.exceptions.WebDriverException: Message: Element is not clickable at point (309.5, 9.75). Other element would receive the click: <section class="content-center clearfix"></section>
I need your help folks!! Thanx in advance
send_keys(Keys.RETURN)to confirm auto-suggestion?<li data-region="16" data-dpt-code="31" ...looks dynamic. Update the question with more of the outerHTML