forked from TalhaBinAshraf1/SeleniumTestingInternetHerokuApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScriptActions.java
More file actions
44 lines (32 loc) · 1.05 KB
/
Copy pathJavaScriptActions.java
File metadata and controls
44 lines (32 loc) · 1.05 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
package allTests;
import org.openqa.selenium.WebElement;
public class JavaScriptActions extends BaseTest{
public static void scrollUp() {
js.executeScript("window.scrollBy(0,-300)");
}
public static void scrollDown() {
js.executeScript("window.scrollBy(0,300)");
}
public static void scrollRight() {
js.executeScript("window.scrollBy(300,0)");
}
public static void scrollLeft() {
js.executeScript("window.scrollBy(-300,0)");
}
public static void pageUp() {
js.executeScript("window.scrollTo(document.body.scrollHeight,0)");
}
public static void pageDown() {
js.executeScript("window.scrollTo(0,document.body.scrollHeight)");
}
public static void scrollToElement(WebElement webElement) {
js.executeScript("arguments[0].scrollIntoView",webElement);
}
public void jsclickElement(WebElement webelement) {
js.executeScript("arguments[0].click()", webelement);
}
public void jsenterText(WebElement webelement, String value) {
webelement.clear();
js.executeScript("arguments[0].value=arguments[1]", webelement,value);
}
}