xpath를 사용하여 날짜를 선택하거나 실제 날짜를 찾을 수 없거나 vipcars.com에서 현재 날짜 옆에 날짜 하나를 선택하고 싶습니다. 은 .. 여기 내가 사용하고 코드의 셀레늄 웹 드라이브를 통해 날짜 선택
public static void main(String args[])
{
System.setProperty("webdriver.chrome.driver","D:\\chromedriver.exe");//any driver can be initialized like this just by replacing driver here.
DesiredCapabilities capabilities=DesiredCapabilities.chrome();
capabilities.setCapability("chrome", true);
WebDriver driver = new ChromeDriver(capabilities);
driver.manage().window().maximize();
// Test URL
driver.get("https://www.vipcars.com/");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
String parent = driver.getWindowHandle();
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[id='supplycarsIframe']")));
driver.findElement(By.id("pickup_country")).click();
Select country = new Select(driver.findElement(By.id("pickup_country")));
country.selectByValue("441");
driver.findElement(By.id("pickup_city")).click();
Select city = new Select(driver.findElement(By.id("pickup_city")));
city.selectByValue("9747");
driver.findElement(By.id("pickup_location")).click();
Select location = new Select(driver.findElement(By.id("pickup_location")));
location.selectByValue("14927");
driver.findElement(By.id("pickdate")).click(); //calender clicks
driver.findElement(By.xpath("//input[@placeholder='From']")); //id found
**driver.findElements(By.xpath("//table[@class='ui-datepicker-calendar']//tr[3]/td[6]"));**
List<WebElement> allDates = (List<WebElement>) ((WebElement) driver.findElements(By.xpath("//table[@class='ui-datepicker-calendar']//tr[3]/td[6]"));
(WebElement) allDates).click();
콘솔 오류 메시지 :
인 java.util.ArrayList가 org.openqa.selenium.WebElement
캐스트 할 수없는
감사 – jackyghai
당신은 나에게 내가 캘린더 요소를 찾기 위해 사용해야 올바른 실제 XPath는 제안시겠습니까 .. : 여기에 코드를 해결하기 위해 몇 가지 예입니다? 나는 xpath를 사용하는 것을 좋아하지 않기 때문에 같은 것에 대한 제안이 필요하다. 나는 현재 날짜 나 현재 날짜 옆의 날짜를 찾아야한다. 실제 Xcode는 무엇이되어야합니까? (vipcars.com) – jackyghai
현재 날짜를 찾으려면'td [@ class = 'ui-datepicker-days-cell-over ui-datepicker-today']'를 사용하십시오. 당신의 xpath에서 10 월 14 일과 11 월 18 일을 얻습니다. – Maze