-1

I am automating make my trip app for practicing. I am working on selenium and python
I am unable to enter from the address and select the autocomplete list.

here is the code

import unittest
from selenium import webdriver

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class PythonOrgSearch(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Chrome()

    def test_search_in_python_org(self):
        driver = self.driver
        driver.get("https://www.makemytrip.com")
        fromaddress = driver.find_element_by_class_name('react-autosuggest__input react-autosuggest__input--open')
        fromaddress.send_keys('Bangalore')
        fromaddress.send_keys(Keys.ARROW_DOWN)
        fromaddress.send_keys(Keys.RETURN)




    def tearDown(self):
        self.driver.close()

if __name__ == "__main__":
    unittest.main()

enter image description here

2

You first have to open the menu, by clicking on the From City text, using ID.

driver.find_element_by_id("fromCity").click()

Then you can query the autocomplete, but fixing the locator you used (only one class is necessary):

driver.find_element_by_css_selector(".react-autosuggest__input--open")
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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