I have found several questions related to this one particular travel website MakeMyTrip, so I tried to automating it.
I was successful in selecting the primary details and getting on the Flight listings page.
I wanted to select the cheapest flight combination out of the available options. Now the website has an option, which always shows the lowest flight combination. I was hoping to use it to book the flight.
Now, the way I thought was doing this-
- Recognising that the cheapest Flights tab is present- using
- Clicking on the Book button to get to next page.
The issue I am facing is recognizing the Cheapest Flight tag. I tried to recognize it by xpath, but the test failed because it didn't find the element. I am using Firebug to check the xpath, and it comes as
I also tried this xpath,
but failed both times.
My question here is:
- Why did the Firebug generated xpath fail?
- Mistake in my xpath
Also I tried removing these checks to directly click on book button but it is also failing, probably because the tag comes a tad second after the page loads. And that is why I was thinking of waiting until the time the tag is loaded and visible on the page.
Here is the piece of code :
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH, "//div[@class='clearfix']//a[@class='stk_btm_chpFlight'][text='cheapest Flights']"))) bookbtn=driver.find_element_by_xpath("//*[@id='content']/div/div/div/div/div/div/div/div/span/span/a") bookbtn.click()