使用一切完成。沒有輸出只顯示一個錯誤。已嘗試所有這些方法,但它只顯示一個錯誤。完全失去了它。昨天沒有任何進展。請考慮一下,請讓我知道。滑塊錯誤總是Selenium Webdriver
public class task {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "g://geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.cheapoair.com/");
driver.manage().deleteAllCookies();
driver.findElement(By.xpath(".//*[@id='ember746']")).sendKeys("DFW");
driver.findElement(By.xpath(".//*[@id='ember751']")).sendKeys("JFK");
driver.findElement(By.xpath(".//*[@id='owFlight']")).click();
driver.findElement(By.xpath(".//*[@id='departCalendar_0']")).click();
driver.findElement(By.xpath(".//*
[@id='calendarCompId']/section/div/div[1]/ol/div[26]/li")).click();
driver.findElement(By.xpath(".//*[@id='ember751']")).sendKeys("JFK");
driver.findElement(By.xpath(".//*[@id='owFlight']")).click();
driver.findElement(By.xpath(".//*
[@id='ember730']/section/form/input")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//WebElement target = driver.findElement(By.xpath(".//*
[@id='DivDepart']/div/div/div[1]/div[2]"));
//WebElement source = driver.findElement(By.xpath(".//*
[@id='DivDepart']/div/div/div[1]/div[1]"));
//a.dragAndDrop(source, target).build().perform();
WebElement slider = driver.findElement(By.xpath(".//*
[@id='DivDepart']/div/div/div[1]/div[2]"));
//WebElement slider = driver.findElement(By.id("DivDepart"));
Actions a = new Actions(driver);
//a.dragAndDropBy(slider, 30, 0).build().perform();
//a.clickAndHold(slider).moveByOffset(30,
0).release(slider).build().perform();
//System.out.println("moved");
//JavascriptExecutor js = (JavascriptExecutor)driver;
org.openqa.selenium.interactions.Action dragAndDrop =
a.clickAndHold(slider).moveByOffset(40,0).release().build();
dragAndDrop.perform();
//js.executeScript("window.scrollBy(200,0)");
}
}
你試圖做什麼?你遇到什麼錯誤?在StackOverflow中轉儲代碼通常沒有幫助.. –
在輸入cheapOair.com後,我試圖移動滑塊,輸入詳細信息後使用xpath並單擊搜索按鈕,新頁面顯示。現在,我需要移動滑塊。當試圖移動它時,它不起作用。 –
它發生了什麼錯誤? –