forked from britka/playwrightium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlaywrightiumOptions.java
161 lines (130 loc) · 4.59 KB
/
PlaywrightiumOptions.java
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package org.brit.options;
import com.microsoft.playwright.options.Geolocation;
import org.brit.emulation.Device;
import org.brit.permission.Permissions;
import org.openqa.selenium.MutableCapabilities;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
/**
* @author Serhii Bryt
* This is Option class for Playwrightium
*/
public class PlaywrightiumOptions extends MutableCapabilities {
/**
* Default constructor
* By default browser id chromium and not in headless mode
*/
public PlaywrightiumOptions() {
super();
setHeadless(false);
setBrowserName("chromium");
setRecordsFolder(Paths.get("build/video"));
setSkipDownloadBrowsers(false);
}
/**
* Sets headless mode
* @param headless
*/
public void setHeadless(boolean headless) {
setCapability("headless", headless);
}
public Boolean getHeadless() {
return (Boolean) getCapability("headless");
}
/**
* Sets browser name.
* Available values are chromium, firefox, webkit
* @param browserName browser name
*/
public void setBrowserName(String browserName) {
setCapability("browserName", browserName);
}
public void setBrowserName(Browsers browserName){
setCapability("browserName", browserName.getValue());
}
/**
* Indicates whether to record video
* @param recordVideo true - record video, false - not
*/
public void setRecordVideo(Boolean recordVideo){
setCapability("recordVideo", recordVideo);
}
public Boolean getRecordVideo(){
return (Boolean) getCapability("recordVideo");
}
/**
* The folder where to save video recordings. Default "build/videos".
* This made to be compatible with Selenide
* @param recordsFolder folder where to save video recordings
*/
public void setRecordsFolder(Path recordsFolder){
setCapability("recordsFolder", recordsFolder);
}
public Path getRecordsFolder(){
return (Path) getCapability("recordsFolder");
}
/**
* Needs only when Playwrightium is used for running tests remotely
* For example, for Aerokube Selenoid, Aerokube Moon, Selenium Grid etc.
* It sets up how we should connect to remotes, using regular method or websocket connection.
* @param connectionByWS if true then we will connect using websocket, otherwise - regular method
* @see <a href='https://aerokube.com/moon/latest/'>Aerokube Moon</a>
* @see <a href='https://aerokube.com/selenoid/latest/'>Aerokube Selenoid</a>
* @see <a href='https://www.selenium.dev/documentation/grid/'>Selenium grid</a>
*/
public void setConnectionByWS(Boolean connectionByWS){
setCapability("connectionByWS", connectionByWS);
}
public Boolean getConnectionByWS(){
return (Boolean) getCapability("connectionByWS");
}
public void setEmulation(Device device){
setCapability("emulation", device);
}
public Device getEmulation(){
return (Device) getCapability("emulation");
}
public void setLocale(Locale locale){
setCapability("locale", locale);
}
public Locale getLocale(){
return (Locale) getCapability("locale");
}
public void setTimeZone(TimeZone timeZone){
setCapability("timeZone", timeZone);
}
public TimeZone getTimeZone(){
return (TimeZone) getCapability("timeZone");
}
public void setGeolocation(Geolocation geolocation){
setCapability("geolocation", geolocation);
}
public Geolocation getGeolocation(){
return (Geolocation) getCapability("geolocation");
}
public void setPermissions(List<Permissions> permissions){
setCapability("permissions", permissions);
}
public List<Permissions> getPermissions(){
return (List<Permissions>) getCapability("permissions");
}
public void setEnableTracing(Boolean enableTracing){
setCapability("enableTracing", enableTracing);
}
public Boolean getEnableTracing(){
return (Boolean) getCapability("enableTracing");
}
public void setTracingOptions(TracingOptions tracingOptions){
setCapability("tracingOptions", tracingOptions);
}
public TracingOptions getTracingOptions(){
return (TracingOptions) getCapability("tracingOptions");
}
public void setSkipDownloadBrowsers(Boolean doNotDownloadBrowsers){
setCapability("skipDownloadBrowsers", doNotDownloadBrowsers);
}
public Boolean getSkipDownloadBrowsers(){
return (Boolean) getCapability("skipDownloadBrowsers");
}
}