简体   繁体   English

如何在 https://www.goibibo.com/hotels 上点击 SELECT ROOM 按钮

[英]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.我需要使用 Selenium 和 ZD272CFAC75B2FBC95E9Z5E22E 在web 页面上单击Select 房间按钮。 However none of the selectors that I have tried seem to work.但是,我尝试过的选择器似乎都不起作用。

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

will not work as it is not unique.将不起作用,因为它不是唯一的。

Have you tried using the Xpath of the "Select Room" button?您是否尝试过使用“选择房间”按钮的 Xpath?

#try this
#insert the xpath of the "Select Room" button element

button = driver.find_element_by_xpath().click()

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 :要为第一个房间类型单击SELECT ROOM按钮,您需要对elementToBeClickable()使用WebDriverWait ,并且可以使用以下任一定位器策略

  • cssSelector : 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=&cc=IN"); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[class^='RoomFlavorstyles__ButtonWrapper']"))).click();
  • xpath : 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=&cc=IN"); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(., 'Select')]"))).click();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Selenium Java 自动化 Goibibo 网站? - How to Automate Goibibo website using Selenium Java? How to select the autocomplete result that contains a certain phrase within the website https://www.easyjet.com/en using Selenium and Java - How to select the autocomplete result that contains a certain phrase within the website https://www.easyjet.com/en using Selenium and Java 如何使用selenium webdriver java从城市字段的GoIbibo中的自动选择下拉列表中选择一个元素 - how to select an element from autoselect drop down in GoIbibo from city field using selenium webdriver java 如何使用 Selenium Java 处理 https://www.spicejet.com/ 的 PASSENGERS 字段的静态下拉列表 - How to handle the static dropdowns of PASSENGERS field of https://www.spicejet.com/ using Selenium Java 如何使用硒登录Goibibo网站 - How to login on Goibibo website using selenium 如何在 Origin.com 中使用 selenium Z93F725A07423321C889DB44 select 登录按钮 - How to select the Sign In button in Origin.com using selenium java 我正在尝试使用Java在Selenium中自动化Goibibo - I am trying to automate Goibibo in Selenium using Java How to extract the text 73 from the text 1-16 of 73 results from the search result summary within https://www.amazon.com using Selenium and Java - How to extract the text 73 from the text 1-16 of 73 results from the search result summary within https://www.amazon.com using Selenium and Java 如何使用Java在Selenium中单击此按钮 - How to click this button in selenium using java 如何使用 Selenium 和 Java 单击确认按钮 - How to click on the Acknowledge Button using Selenium and Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM