Reputation: 107
I am able to enter the location, but once I am done with sending the location, then it should automatically click the 1st item from suggestion, but it is not working. Any work around on this?
I have tried almost all the things like inducing some wait time in order to load the suggestion and then press enter but nothing has helped me. I am newbie in selenium and python.
url = 'https://www.stek-usa.com/locator'
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.implicitly_wait(10)
driver.get(url)
loc = driver.find_element_by_id('storelocator-search_address')
loc.send_keys('Arkansas, USA')
loc.click()
loc.send_keys(Keys.RETURN)
Once enter is pressed, it should show the correct location. But that is not happening. Please help me on this.
Upvotes: 1
Views: 702
Reputation: 514
Try this way: driver.sendKeys(Keys.chord("your location", Keys.ENTER));
This step will perform entering your location into text box and will click on first matching option, which will fulfill your criteria
Upvotes: 0
Reputation: 8394
Try the following, instead of the last three lines of your code, add this:
loc.send_keys('Arkansas, USA' + Keys.DOWN + Keys.RETURN)
Upvotes: 2