如何自动滑块?我尝试过clickandhold,movetoelement by offset。
我的问题是:脚本停止在我的代码的拖放行中执行,当我手动将鼠标指向它执行拖放操作的元素时
String driverPath;
driverPath = "D:/software wishes/jdk and jre/geckodriver-v0.16.1-win64/";
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://automationpractice.com/index.php");
WebDriverWait wait = new WebDriverWait(driver, 80);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@class='sf-with-ul' and text()='Women']")));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[@class='sf-with-ul' and text()='Women']")));
Actions action = new Actions(driver);
WebElement element=driver.findElement(By.xpath("//a[@class='sf-with-ul' and text()='Women']"));
action.moveToElement(element).build().perform();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("T-shirts")));
wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("T-shirts")));
WebElement tops = driver.findElement(By.linkText("T-shirts"));
action.moveToElement(tops);
action.click().build().perform();
By locator = By.cssSelector(".ui-slider-handle.ui-state-default.ui-corner-all.ui-state-hover");
wait.until(ExpectedConditions.presenceOfElementLocated(locator));
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
WebElement sliderRight = driver.findElement(locator);
action.dragAndDropBy(sliderRight,-40,0).build().perform();