자동화를 시도했지만 로케이터가 보이지 않고 div 클래스가 동적으로 추가됩니다. 어느 누구도 나를 도와 줄 수 있습니까 ??selenium webdriver를 사용하여 부트 스트랩 데이트 피커를 자동화 하시겠습니까?
-2
A
답변
0
친구 부트 스트랩 날짜 선택 도구가 자동화되었습니다. 나는이 코드가 나 같은 사람이 될지도 모른다는 것을 공유하고있다.
driver.findElement(By.id("datepicker")).click();//to click on thedate picker field
String date_ent = "17-May-2017";
String date_ent1[] = date_ent.split("-");
String shipFDay = date_ent1[0];
String shipFMonth = date_ent1[1];
String shipFYear = date_ent1[2];
String date_pres = driver.findElement(By.xpath("//th[@title='Select Month']")).getText();
System.out.println(date_pres);
String dp[] = date_pres.split(" ");
String month_pres = dp[0];
String year_pres = dp[1];
if (year_pres.equals(shipFYear)) {
driver.findElement(By.xpath("//th[@title='Select Month']")).click();
driver.findElement(By.xpath("//span[contains(.,'" + shipFMonth + "')]")).click();
Thread.sleep(5000);
} else if (Integer.parseInt(year_pres) > Integer.parseInt(shipFYear)) {
driver.findElement(By.xpath("//th[@title='Select Month']")).click();
while (2 > 1) {
year_pres = driver.findElement(By.xpath("//th[@title='Select Year']")).getText();
if (year_pres.equalsIgnoreCase(shipFYear)) {
driver.findElement(By.xpath("//span[contains(.,'" + shipFMonth + "')]")).click();
Thread.sleep(5000);
break;
}
driver.findElement(By.xpath("//span[@title='Previous Year']")).click();
}
} else {
driver.findElement(By.xpath("//th[@title='Select Month']")).click();
while (2 > 1) {
year_pres = driver.findElement(By.xpath("//th[@title='Select Year']")).getText();
if (year_pres.equalsIgnoreCase(shipFYear)) {
driver.findElement(By.xpath("//span[contains(.,'" + shipFMonth + "')]")).click();
Thread.sleep(5000);
break;
}
driver.findElement(By.xpath("//span[@title='Next Year']")).click();
}
}
switch (shipFMonth) {
case "Jan": {
driver.findElement(By.xpath("//td[@data-day='01/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Feb": {
driver.findElement(By.xpath("//td[@data-day='02/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Mar": {
driver.findElement(By.xpath("//td[@data-day='03/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Apr": {
driver.findElement(By.xpath("//td[@data-day='04/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "May": {
driver.findElement(By.xpath("//td[@data-day='05/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Jun": {
driver.findElement(By.xpath("//td[@data-day='06/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Jul": {
driver.findElement(By.xpath("//td[@data-day='07/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Aug": {
driver.findElement(By.xpath("//td[@data-day='08/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Sep": {
driver.findElement(By.xpath("//td[@data-day='09/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Oct": {
driver.findElement(By.xpath("//td[@data-day='10/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Nov": {
driver.findElement(By.xpath("//td[@data-day='11/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
case "Dec": {
driver.findElement(By.xpath("//td[@data-day='12/" + shipFDay + "/" + shipFYear + "']")).click();
System.out.println("Date Selected");
break;
}
default: {
System.out.println("Please enter the date in the standard format like DD-MMM-yyyy");
break;
}
}
0
JS를 통해 '업데이트'메소드를 호출하여 날짜를 설정했다고 생각하십니까? =>https://bootstrap-datepicker.readthedocs.io/en/latest/methods.html#update 다음 명령을 사용하여 콘솔을 통해 날짜를 설정할 수있었습니다 : "$ ('sandbox-container div') datepicker ('update', '2011-03-05');" => 그와 https://uxsolutions.github.io/bootstrap-datepicker/?markup=embedded&format=&weekStart=&startDate=&endDate=&startView=0&minViewMode=0&maxViewMode=4&todayBtn=false&clearBtn=false&language=en&orientation=auto&multidate=&multidateSeparator=&keyboardNavigation=on&forceParse=on#sandbox
, 당신은이
당신이 우리에게 보여주는 작업의 일부 주시겠습니까 명령을 해고하는 JavascriptExecutor를 사용할 수 있습니까? – DebanjanB