캘린더 팝업에서 출발일과 반환 날짜를 선택하려고하지만 날짜 선택을위한 제네릭 코드를 작성하기가 어렵습니다. 어떤 날짜가 main 메소드에서 인수로 전달되고 메서드가 실행되고 캘린더 팝업을 클릭하고 date를 클릭하여 선택합니다. 나는 그 달을 찾을 때까지 코드를 작성했지만 그 후에는 날짜 경로에 붙어 있습니다. 팝업의이클립스에서 셀렌 경로를 사용하여 캘린더 팝업에서 날짜를 선택하는 방법
스크린 샷 : 내가 사용하고
웹 사이트는 https://www.yatra.com/
Here is my code:
package Website;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class PickDateCalender {
static WebDriver driver=new FirefoxDriver();;
public static void main(String[] args) throws InterruptedException {
driver.get("https://www.yatra.com/");
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
WebElement element=driver.findElement(By.className("dropdown-toggle"));
String ori="New Delhi, India (DEL)";
String dest="Bangalore, India (BLR)";
String DepartDte="23-October-2016";
String splitter[]=DepartDte.split("-");
String Departdate=splitter[0];
System.out.println("date"+" "+Departdate);
String Departmonth=splitter[1];
System.out.println("month"+" "+Departmonth);
String Departyear=splitter[2];
System.out.println("year"+" "+Departyear);
String returDte="";
;
selectDate(Departdate,Departmonth,Departyear);
}
public static void selectDate(String Depardate,String Departmonth,String Departyear){
WebElement Depart=driver.findElement(By.id("BE_flight_depart_date"));
Depart.click();
List <WebElement> month =driver.findElements(By.xpath(".//*[@id='PegasusCal-0']//ul[@class='month-list']"));
for(int i=0;i<month.size();i++){
String monname=month.get(i).getText();
if(monname.contains(Departmonth)){
System.out.println("Match found"+" "+monname);
System.out.println("inside if");
month.get(i).click();
break;
}
driver.close();
}
}
}
당신이 원하는 것 –
괜찮아요. 내가 쿼리 plzz revertr을 check.I 업데이 트됩니다 내 쿼리를 업데이 트가 충분히 좋은거야 ?? –
http://seleniumtutorialpoint.com/2015/02/how-to-handle-calendar-pop-up-in-selenium-webdriver/ 및 http://www.mythoughts.co.in/2013/04를 참조하십시오. /selecting-date-from-datepicker-using.html#.WApfSisRCUI 및 http://www.guru99.com/handling-date-time-picker-using-selenium.html –