0

I'm trying to select the first value of the drop down from the autosuggested list when I use sendkey with a value of 'ada' into the "Enter Company" field on the following page. http://www.moneycontrol.com/stocks/histstock.php

inputElement = driver.find_element_by_xpath("""//*[@id="mycomp"]""")
inputElement.send_keys('ada')   
driver.find_element_by_xpath("""//*[@id="suggest"]/ul/li[1]""")

This doesn't seem to do the trick.

Please help.

Regards,

babsdoc

1 Answer 1

1

Try to wait until required option appears in DOM:

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

driver.find_element_by_id("mycomp").send_keys('ada')
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="suggest"]/ul/li[1]'))).click()
1
  • That worked like a charm Andersson. Thank you for your help, sincerely appreciated.
    – babsdoc
    Jul 10, 2017 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.