-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDriverPlugin.java
More file actions
136 lines (120 loc) · 5.41 KB
/
DriverPlugin.java
File metadata and controls
136 lines (120 loc) · 5.41 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
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
package com.nordstrom.automation.selenium;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import com.nordstrom.automation.selenium.AbstractSeleniumConfig.SeleniumSettings;
import com.nordstrom.automation.selenium.core.GridUtility;
import com.nordstrom.automation.selenium.core.LocalSeleniumGrid.LocalGridServer;
import net.bytebuddy.implementation.Implementation;
/**
* This interface defines the contract for driver plug-in objects.
*/
public interface DriverPlugin {
/**
* Get dependency contexts for this driver.
*
* @return driver dependency contexts
*/
String[] getDependencyContexts();
/**
* Get driver capabilities as JSON string.
*
* @param config {@link SeleniumConfig} object
* @return JSON driver capabilities
*/
String getCapabilities(SeleniumConfig config);
/**
* Get name of browser supported by this plug-in.
*
* @return browser name
*/
String getBrowserName();
/**
* Get driver "personalities" provided by this plug-in.
*
* @return named collection of capabilities records
*/
Map<String, String> getPersonalities();
/**
* Get names of supported System properties.
*
* @param capabilities required capabilities for target driver
* @return System property names
*/
String[] getPropertyNames(String capabilities);
/**
* Start local Selenium Grid node for this driver.
*
* @param config {@link SeleniumConfig} object
* @param hubUrl Grid hub {@link URL} with which node should register
* @return {@link LocalGridServer} object for specified node
* @throws IOException if an I/O error occurs
*/
default LocalGridServer create(SeleniumConfig config, URL hubUrl) throws IOException {
String launcherClassName = config.getString(SeleniumSettings.GRID_LAUNCHER.key());
String[] dependencyContexts = config.getDependencyContexts();
String workingDir = config.getString(SeleniumSettings.GRID_WORKING_DIR.key());
Path workingPath = (workingDir == null || workingDir.isEmpty()) ? null : Paths.get(workingDir);
return create(config, launcherClassName, dependencyContexts, hubUrl, workingPath);
}
/**
* Start local Selenium Grid node for this driver.
*
* @param config {@link SeleniumConfig} object
* @param launcherClassName fully-qualified name of {@code GridLauncher} class
* @param dependencyContexts fully-qualified names of context classes for Selenium Grid dependencies
* @param hubUrl Grid hub {@link URL} with which node should register
* @param workingPath {@link Path} of working directory for server process; {@code null} for default
* @return {@link LocalGridServer} object for specified node
* @throws IOException if an I/O error occurs
*/
default LocalGridServer create(SeleniumConfig config, String launcherClassName, String[] dependencyContexts,
URL hubUrl, Path workingPath) throws IOException {
Path outputPath = GridUtility.getOutputPath(config, false);
LocalGridServer nodeServer =
create(config, launcherClassName, dependencyContexts, hubUrl, workingPath, outputPath);
nodeServer.getPersonalities().putAll(getPersonalities());
return nodeServer;
}
/**
* Start local Selenium Grid node for this driver.
*
* @param config {@link SeleniumConfig} object
* @param launcherClassName fully-qualified class name for Grid launcher
* @param dependencyContexts common dependency contexts for all Grid nodes
* @param hubUrl Grid hub {@link URL} with which node should register
* @param workingPath {@link Path} of working directory for server process; {@code null} for default
* @param outputPath {@link Path} to output log file; {@code null} to decline log-to-file
* @return {@link LocalGridServer} object for specified node
* @throws IOException if an I/O error occurs
*/
LocalGridServer create(SeleniumConfig config, String launcherClassName, String[] dependencyContexts,
URL hubUrl, Path workingPath, Path outputPath) throws IOException;
/**
* Get constructor for this driver's {@link RemoteWebDriver} implementation.
* <p>
* <b>NOTE</b>: This is only needed for implementations that require driver-specific implementation.
*
* @param <T> constructor type parameter
* @param desiredCapabilities desired capabilities for the driver
* @return constructor for driver-specific {@link RemoteWebDriver} implementation
*/
<T extends RemoteWebDriver> Constructor<T> getRemoteWebDriverCtor(Capabilities desiredCapabilities);
/**
* Get default constructor for this driver's {@link WebElement} implementation.
* <p>
* <b>NOTE</b>: This is only needed for implementations that use non-default constructors.
*
* @param driver target driver instance
* @param refClass class of {@code WebDriver} implementation
* @return default constructor implementation
*/
Implementation getWebElementCtor(WebDriver driver, Class<? extends WebElement> refClass);
}