【发布时间】:2021-10-08 18:19:02
【问题描述】:
#如何在 goibibo/hotels.com(孟买地区)中使用 selenium 选择入住和退房日期# 假设我想选择入住日期 2021 年 8 月 25 日和退房日期 2021 年 9 月 3 日
https://www.goibibo.com/hotels/
package com.bean;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Goibibo {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver_2\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
//Goto Url Goibibo.com
driver.get("https://www.goibibo.com/hotels/");
System.out.println("WWW.GOIBIBO.COM");
//Select Country India
driver.findElement(By.xpath("//input[@name='CountryType']")).click();
System.out.println("Selected Country India");
// Click on Search Bar
driver.findElement(By.id("downshift-1-input")).click();
System.out.println("Clicked On Search Bar");
//Select Mumbai City
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//p[text()='Mumbai']"))).click();
System.out.println("Print Mumbai !");
driver.findElement(By.id("search-widget-checkin-input")).click();
System.out.println("Select Check In");
}
}
【问题讨论】:
-
您的代码在哪里?你试过什么?遇到了什么错误?
-
您要选择哪个日期?您尝试过任何代码吗?任何错误堆栈跟踪?
-
是的,我试过了,假设我想选择 21 August 2021 。我将添加代码
标签: selenium selenium-webdriver datepicker css-selectors selenium-chromedriver