How to click on SELECT ROOM button on https://www.goibibo.com/hotels using Selenium and Java

I need to click on the Select Room button on this web page using Selenium and Xpath. However none of the selectors that I have tried seem to work.

//button[contains(text(), 'Select')] 

will not work as it is not unique.

Add Comment
2 Answer(s)

Have you tried using the Xpath of the "Select Room" button?

#try this #insert the xpath of the "Select Room" button element  button = driver.find_element_by_xpath().click() 
Add Comment

To click on SELECT ROOM button for the first Room Type you need to use WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    driver.get("https://www.goibibo.com/hotels/sterling-ooty-elk-hill-hotel-in-Ooty-2300020804682931682/?hquery=%7B%22ci%22:%2220200715%22,%22co%22:%2220200716%22,%22r%22:%221-2-0%22,%22ibp%22:%22v3%22%7D&hmd=dacdbc1b43518ece5284c57e889be4a87cc77193f605a25ed4ddbe075bfe72b50c00212e846ffe0c4d7c14c0c2e99e1f40aca6cc0f778c8744e79e26f88866c20ebbd2cee32e2b6cf2c8b5af0de595bae20e654d05992eb728f7ddf37568b56d5c81bb8ac295450b84325b36e5120e8a6c03a734f1db8b74774fdff16746415297313331343db0030c5fc7459538a2014739addf9286645500cac56ad4f8c63de9aa897df81e7b5c4a65a87cb547f68c67f73b28ab81b51b5c7eb9f44b74bbeb13e8f020604d6a6122c86b4ac1988d80e57a2632e518ee111133feebf7fc7b19dc7ca235d802fc3723de2910739aa363191808950f137910bc50af1b78aefe5f7cb119732470e54ceae95944fe242a583e96e7e68ed5618ddbb9f3df324bddee3639f3fe60a0b43aae1903c5c70296b3f530f37909cfed64d6bac2db1529e3759c957d466f83bd58380f3d18ebd39a58195250cdff3970687780870948e8&cc=IN"); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[class^='RoomFlavorstyles__ButtonWrapper']"))).click(); 
  • xpath:

    driver.get("https://www.goibibo.com/hotels/sterling-ooty-elk-hill-hotel-in-Ooty-2300020804682931682/?hquery=%7B%22ci%22:%2220200715%22,%22co%22:%2220200716%22,%22r%22:%221-2-0%22,%22ibp%22:%22v3%22%7D&hmd=dacdbc1b43518ece5284c57e889be4a87cc77193f605a25ed4ddbe075bfe72b50c00212e846ffe0c4d7c14c0c2e99e1f40aca6cc0f778c8744e79e26f88866c20ebbd2cee32e2b6cf2c8b5af0de595bae20e654d05992eb728f7ddf37568b56d5c81bb8ac295450b84325b36e5120e8a6c03a734f1db8b74774fdff16746415297313331343db0030c5fc7459538a2014739addf9286645500cac56ad4f8c63de9aa897df81e7b5c4a65a87cb547f68c67f73b28ab81b51b5c7eb9f44b74bbeb13e8f020604d6a6122c86b4ac1988d80e57a2632e518ee111133feebf7fc7b19dc7ca235d802fc3723de2910739aa363191808950f137910bc50af1b78aefe5f7cb119732470e54ceae95944fe242a583e96e7e68ed5618ddbb9f3df324bddee3639f3fe60a0b43aae1903c5c70296b3f530f37909cfed64d6bac2db1529e3759c957d466f83bd58380f3d18ebd39a58195250cdff3970687780870948e8&cc=IN"); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(., 'Select')]"))).click(); 
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.