Class AbstractDriver
- java.lang.Object
-
- com.dkfqs.selenium.seleniumdriver.AbstractDriver
-
- Direct Known Subclasses:
AbstractChromeDefaultDriver,AbstractEdgeDefaultDriver,AbstractFirefoxDefaultDriver
public abstract class AbstractDriver extends java.lang.ObjectThe abstract class for all selenium web drivers.
Public fields are:public Logger logger; public final ByteArrayOutputStream driverServiceOutputStream = new ByteArrayOutputStream(); public WebDriver driver; public Map<String, Object> vars; public JavascriptExecutor js;
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractDriver.WebBrowserTypeThe annotation for the 'WebBrowserType', supported values are 'Chrome', 'Edge', and 'Firefox'
-
Field Summary
Fields Modifier and Type Field Description org.openqa.selenium.WebDriverdriverThe web driver.java.io.ByteArrayOutputStreamdriverServiceOutputStreamThe driver service output stream.org.openqa.selenium.JavascriptExecutorjsThe JavaScript executor.java.util.logging.LoggerloggerThe logger.static java.util.HashSet<java.lang.String>VALID_WEB_BROWSER_TYPES_SETA set of all valid web browser types.java.util.Map<java.lang.String,java.lang.Object>varsThe map of variables.static java.lang.StringWEB_BROWSER_TYPE_CHROMEWeb browser type: Chrome.static java.lang.StringWEB_BROWSER_TYPE_EDGEWeb browser type: Edge.static java.lang.StringWEB_BROWSER_TYPE_FIREFOXWeb browser type: Firefox.
-
Constructor Summary
Constructors Constructor Description AbstractDriver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabstractSetUp()Setup the abstract driver.voidabstractTearDown()Tear down the driver.static java.lang.StringformatDate(long millis)Format a Unix-like timestamp to yyyy-MM-dd HH:mm:ss.SSS .static java.io.FilegetArgDataOutputDirectory()Get the data output directory.static java.lang.StringgetUserInputField(java.lang.String variableName, java.lang.String defaultValue)Get the value of a user input field.static intgetUserNumber()Get the simulated user number.static booleanisArgDebugExecution()Get if debug test execution is enabled.static booleanisArgDebugMeasuring()Get if debug data measuring is enabled.java.lang.StringtakeScreenshotAsBase64()Take a screenshot and get the data of the png image in base64 format.byte[]takeScreenshotAsBinary()Take a screenshot and get the bytes of the png image.voidtakeScreenshotAsFile(java.io.File f)Take a screenshot and save it as file.java.io.FiletakeScreenshotAsTestJobOutFile(java.lang.String fileName)Take a screenshot and save it as file in the "out" directory of the current measuring agent job.
-
-
-
Field Detail
-
WEB_BROWSER_TYPE_CHROME
public static final java.lang.String WEB_BROWSER_TYPE_CHROME
Web browser type: Chrome.- See Also:
- Constant Field Values
-
WEB_BROWSER_TYPE_EDGE
public static final java.lang.String WEB_BROWSER_TYPE_EDGE
Web browser type: Edge.- See Also:
- Constant Field Values
-
WEB_BROWSER_TYPE_FIREFOX
public static final java.lang.String WEB_BROWSER_TYPE_FIREFOX
Web browser type: Firefox.- See Also:
- Constant Field Values
-
VALID_WEB_BROWSER_TYPES_SET
public static final java.util.HashSet<java.lang.String> VALID_WEB_BROWSER_TYPES_SET
A set of all valid web browser types.
-
logger
public java.util.logging.Logger logger
The logger. The default log level is INFO, if isArgDebugExecution() == true then the level is FINE.- See Also:
isArgDebugExecution()
-
driverServiceOutputStream
public final java.io.ByteArrayOutputStream driverServiceOutputStream
The driver service output stream.
-
driver
public org.openqa.selenium.WebDriver driver
The web driver.
-
vars
public java.util.Map<java.lang.String,java.lang.Object> vars
The map of variables.
-
js
public org.openqa.selenium.JavascriptExecutor js
The JavaScript executor.
-
-
Method Detail
-
isArgDebugExecution
public static boolean isArgDebugExecution()
Get if debug test execution is enabled.- Returns:
- true if debug test execution is enabled
-
isArgDebugMeasuring
public static boolean isArgDebugMeasuring()
Get if debug data measuring is enabled.- Returns:
- true if debug data measuring is enabled
-
getArgDataOutputDirectory
public static java.io.File getArgDataOutputDirectory()
Get the data output directory.- Returns:
- the data output directory, or null if no such information is available
-
getUserNumber
public static int getUserNumber()
Get the simulated user number.- Returns:
- the simulated user number, or -1 if no such information is available
-
getUserInputField
public static java.lang.String getUserInputField(java.lang.String variableName, java.lang.String defaultValue)Get the value of a user input field.- Parameters:
variableName- the variable name of the user input fielddefaultValue- the default value- Returns:
- the value of a user input field, or the default value if the user input field is undefined
-
abstractSetUp
public void abstractSetUp()
Setup the abstract driver. This method initializes the logger of the driver.
-
abstractTearDown
public void abstractTearDown()
Tear down the driver. This method performs:- Call: driver.quit()
- Dump the log of the driver service to stdout (only if isArgDebugExecution() == true)
- Dump the web browser log to stdout
- See Also:
isArgDebugExecution()
-
formatDate
public static java.lang.String formatDate(long millis)
Format a Unix-like timestamp to yyyy-MM-dd HH:mm:ss.SSS .- Parameters:
millis- the Unix-like timestamp- Returns:
- the formatted string
-
takeScreenshotAsFile
public void takeScreenshotAsFile(java.io.File f) throws java.io.IOExceptionTake a screenshot and save it as file.- Parameters:
f- the file (the file name should end with .png)- Throws:
java.io.IOException- if the file cannot be written
-
takeScreenshotAsTestJobOutFile
public java.io.File takeScreenshotAsTestJobOutFile(java.lang.String fileName) throws java.io.IOExceptionTake a screenshot and save it as file in the "out" directory of the current measuring agent job.- Parameters:
fileName- the file name (should end with .png)- Returns:
- the saved file
- Throws:
java.io.IOException- if the file cannot be written
-
takeScreenshotAsBinary
public byte[] takeScreenshotAsBinary()
Take a screenshot and get the bytes of the png image.- Returns:
- the bytes of the png image
-
takeScreenshotAsBase64
public java.lang.String takeScreenshotAsBase64()
Take a screenshot and get the data of the png image in base64 format.- Returns:
- the data of the png image in base64 format
-
-