0

I'm trying to enter an address then they propose me some addresses and I had no idea how to select the first option they give me.

If you want to try, at the second step on this link: https://www.sneakql.com/en-GB/launch/culturekings/womens-air-jordan-1-high-og-court-purple-au/register

adresse = chrome.find_element_by_id('address-autocomplete') adresse.send_keys(row['Adresse']) #Adress from a file time.sleep(5) country = chrome.find_element_by_xpath('//li[@id="suggestion_0"]').click(); 

Inspect element:

Inspect element

3
  • That's not a normal Select option drop down. You need to click on input box and then store all option in a list and then iterate the list and click on your desired element. Paste the HTML in normal text here.CommentedJun 1, 2021 at 14:43
  • Please add a code that you are executing
    – vitaliis
    CommentedJun 1, 2021 at 15:01
  • Next time when posting a question add there full code to reproduce the issue. It will be easier to answer the question and you will get less downvotes.
    – vitaliis
    CommentedJun 1, 2021 at 15:56

2 Answers 2

2

Try clicking on the first option with this:

driver.find_element_by_xpath('//li[@id="suggestion_0"]') 

UPD
The element you trying to click is out of the view. You have to do the following:

from selenium.webdriver.common.action_chains import ActionChains suggestion_0 = driver.find_element_by_xpath('//li[@id="suggestion_0"]') actions = ActionChains(driver) actions.move_to_element(suggestion_0).perform() suggestion_0.click() 
1
  • Error : selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <li class="jss50" role="option" aria-setsize="1" aria-posinset="1" id="suggestion_0">...</li> is not clickable at point (456, 739). Other element would receive the click: <li class="jss50" role="option" aria-setsize="1" aria-posinset="1" id="suggestion_0">...</li>
    – abc
    CommentedJun 1, 2021 at 14:54
1

You should click this field and wait for the first option to become clickable.

I've wrote some code to test if my solution works and it works in all cases for me:

from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By url = 'https://www.sneakql.com/en-GB/launch/culturekings/womens-air-jordan-1-high-og-court-purple-au/register' driver = webdriver.Chrome(executable_path='/snap/bin/chromium.chromedriver') driver.get(url) wait = WebDriverWait(driver, 15) wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'AGREE')]"))).click() # ACCEPT COOKIES # Making inputs of the first page wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#firstName"))).send_keys("test") wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#lastName"))).send_keys("Last name") wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#preferredName"))).send_keys("Mr. President") wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#email"))).send_keys("[email protected]") driver.find_element_by_css_selector("#password").send_keys("11111111") driver.find_element_by_css_selector("#phone").send_keys("222334413") driver.find_element_by_css_selector("#birthdate").send_keys("2000-06-11") wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'Next')]"))).click() # Second page and answer to your main question wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#address-autocomplete"))).send_keys("street") wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#suggestion_0"))).click() 

Please note, that not all explicit waits are required and I used css selectors because I am not sure that all elements ids are correct.

My output: enter image description here

0

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.