[英]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.