public class IbiboCalendar {
WebDriver driver;
String selectDepartureDate = "07/25/2017";
@SuppressWarnings("deprecation")
Date selectedDepartureDate = new Date(selectDepartureDate);
SimpleDateFormat simpleDepartureDate = new SimpleDateFormat("MMMM/dd/yyyy");
String formattedDeaparturedate = simpleDepartureDate.format(selectedDepartureDate);
String[] split = formattedDeaparturedate.split("/");
String departureMonth = split[0]+" "+split[2];
String departureDate = split[1];
@FindBy(css = "input[placeholder = 'Choose Date']")
WebElement iDepartDateCalendarBox;
public IbiboCalendar(WebDriver driver){
this.driver = driver;
PageFactory.initElements(driver, this);
}
public void goToDepartDateCalendarBox() throws InterruptedException{
iDepartDateCalendarBox.click();
Thread.sleep(2000);
while(true){
try{
driver.findElement(By.xpath("//div[@class = 'DayPicker-Month.DayPicker-Caption'] and [contains(text(),'"+departureMonth+"')]")).isDisplayed();
driver.findElement(By.xpath("//div[@class = 'DayPicker-Day.calDate'] and [contains(text(),'"+departureDate+"')]")).click();
break;
}
catch(Exception e){
driver.findElement(By.xpath("//*[@class= 'DayPicker-NavButton DayPicker-NavButton--next']")).click();
Thread.sleep(1000);
}
}
}
webdriverをセレン、私は私が直面date.Theの問題を選択し、そのオブジェクトを作成することにより、上記のクラスを呼び出していますが、システムが "をクリックし続け、あります次の "矢印ボタンをクリックします。また、xpathセレクタ構文にエラーが表示されます。私を助けてください。
public class IbiboTest {
static WebDriver driver;
@BeforeClass
public void setUp() throws InterruptedException{
System.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
driver = new ChromeDriver();
//driver= new FirefoxDriver();
driver.get("https://www.goibibo.com/");
Thread.sleep(5000);
driver.manage().window().maximize();
}
@Test
public void testIbiboHomePage() throws InterruptedException{
IbiboHomePage home = PageFactory.initElements(driver, com.Nalini.Ibibo.IbiboHomePage.class);
home.clickRoundTripRadioButton();
home.goToFromSelectionBox();
Thread.sleep(5000);
home.goToToSelectionBox();
Thread.sleep(5000);
IbiboCalendar calendar = PageFactory.initElements(driver, com.Nalini.Ibibo.IbiboCalendar.class);
calendar.goToDepartDateCalendarBox();
Thread.sleep(5000);
}
私はそれを得ることができ、私は全体calendar.HowのHTMLコードを取得することができません日付ピッカー – kushal
のためのHTMLコードが必要です。 – Nal
要素を右クリックしてから要素を検査してください – kushal