简体   繁体   English

Selenium WebDriver滑块

[英]Selenium WebDriver Slider

I need it to move a slider bar to the right. 我需要将滑块向右移动。 I've seen on other posts that WebElement is used but I'm unsure still. 我在其他文章中看到使用了WebElement,但是我不确定。

here is what I tried: 这是我尝试过的:

 WebElement Slider = driver.findElement(By.cssSelector("#tipAmount"));
    Thread.sleep(3000);

    Actions moveSlider = new Actions(driver);
    Action action = (Action) moveSlider.dragAndDropBy(Slider, 30, 0).build();

    moveSlider.perform();

I haven't done many Actions but from what I can tell from looking at a sample it looks like you need to do 我没有做很多动作,但是从看样本可以看出来,看来您需要做

action.perform();

instead of 代替

moveSlider.perform();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM