blob: 45c1e69f0142f501040000303d3c782da63c0ff2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package com.mavlushechka.a1qa.elements;
import com.mavlushechka.a1qa.driverUtils.ActionUtils;
import com.mavlushechka.a1qa.utils.DoubleUtils;
import com.mavlushechka.a1qa.utils.LoggerUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
public class Slider extends BaseElement {
public Slider(By locator, String name) {
super(locator, name);
}
public void slideTo(int percentage) {
WebElement slider = find();
Point currentPoint = new Point((int) Math.round(DoubleUtils.getPercentageOf(slider.getSize().getWidth(), getValue())-getDimension().width/2.0), 0);
Point expectedPoint = new Point((int) Math.round(DoubleUtils.getPercentageOf(slider.getSize().getWidth(), percentage)-getDimension().width/2.0), 0);
LoggerUtils.info("Sliding on the \"" + getName() + "\" element.");
ActionUtils.dragAndDrop(slider, currentPoint, expectedPoint);
}
public int getValue() {
return Integer.parseInt(find().getAttribute("value"));
}
}
|