Package io.webfolder.cdp.session
Class Session
java.lang.Object
io.webfolder.cdp.session.Session
- All Implemented Interfaces:
Constant
,Dom
,JavaScript
,Keyboard
,Mouse
,Navigator
,Selector
,java.lang.AutoCloseable
public class Session extends java.lang.Object implements java.lang.AutoCloseable, Selector, Keyboard, Mouse, Navigator, JavaScript, Dom
-
Field Summary
Fields inherited from interface io.webfolder.cdp.session.Constant
BACKSPACE, DOM_PROPERTIES, DOWN_ARROW, EMPTY_ARGS, EMPTY_NODE_ID, ENTER, ESC, LEFT_ARROW, RIGHT_ARROW, SPECIAL_KEYS, TAB, UP_ARROW, WAIT_PERIOD, WAIT_TIMEOUT
-
Method Summary
Modifier and Type Method Description void
activate()
Activate this browser windowvoid
addEventListener(EventListener eventListener)
UseSession#getListenerManager()
byte[]
captureScreenshot()
Capture page screenshot.byte[]
captureScreenshot(boolean hideScrollbar)
Capture page screenshot.byte[]
captureScreenshot(boolean hideScrollbar, ImageFormat format, java.lang.Integer quality, Viewport clip, java.lang.Boolean fromSurface)
Capture page screenshot.void
close()
Close the this browser windowSession
enableConsoleLog()
Redirects javascript console logs to slf4jSession
enableDetailLog()
Redirects runtime logs (network, security, storage etc..) to slf4jSession
enableNetworkLog()
Redirects network logs to slf4jboolean
equals(java.lang.Object obj)
java.lang.String
getBrowserContextId()
Command
getCommand()
java.lang.Integer
getExecutionContextId()
java.lang.String
getFrameId()
java.lang.String
getId()
<T> T
getJsFunction(java.lang.Class<T> klass)
int
getMajorVersion()
java.lang.String
getTargetId()
Session
getThis()
int
hashCode()
boolean
isConnected()
Session
navigate(java.lang.String url)
Session
navigateAndWait(java.lang.String url, WaitUntil condition)
Session
navigateAndWait(java.lang.String url, WaitUntil condition, int timeout)
void
onTerminate(TerminateListener terminateListener)
<T> T
registerJsFunction(java.lang.Class<T> klass)
void
removeEventEventListener(EventListener eventListener)
UseSession#getListenerManager()
java.lang.String
toString()
Session
wait(int timeout)
Causes the current thread to wait until waiting time elapses.Session
wait(int timeout, boolean log)
Causes the current thread to wait until waiting time elapses.Session
waitDocumentReady()
waits until document is readySession
waitDocumentReady(int timeout)
waits until document is readyboolean
waitUntil(java.util.function.Predicate<Session> predicate)
boolean
waitUntil(java.util.function.Predicate<Session> predicate, int timeout)
boolean
waitUntil(java.util.function.Predicate<Session> predicate, int timeout, int period)
boolean
waitUntil(java.util.function.Predicate<Session> predicate, int timeout, int period, boolean log)
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.webfolder.cdp.session.Dom
clearOptions, clearOptions, focus, focus, focus, getAttribute, getAttribute, getAttribute, getAttributes, getAttributes, getAttributes, getBoxModel, getBoxModel, getClickablePoint, getClickablePoint, getOptions, getOptions, getOuterHtml, getOuterHtml, getSelectedIndex, getSelectedIndex, getText, getText, getValue, getValue, isChecked, isChecked, isDisabled, isDisabled, scrollIntoViewIfNeeded, scrollIntoViewIfNeeded, selectInputText, selectInputText, setAttribute, setAttribute, setAttribute, setChecked, setChecked, setDisabled, setDisabled, setFiles, setFiles, setSelectedIndex, setSelectedIndex, setSelectedOptions, setSelectedOptions, setValue, setValue
Methods inherited from interface io.webfolder.cdp.session.JavaScript
callFunction, callFunction, callFunction, evaluate, getVariable, setVariable
Methods inherited from interface io.webfolder.cdp.session.Keyboard
sendBackspace, sendDownArrow, sendEnter, sendEsc, sendKeyCode, sendKeys, sendLeftArrow, sendRightArrow, sendTab, sendUpArrow
Methods inherited from interface io.webfolder.cdp.session.Navigator
back, clearCache, clearCookies, forward, getContent, getLocation, getPathname, getQueryString, getTitle, isDomReady, reload, setUserAgent, stop
Methods inherited from interface io.webfolder.cdp.session.Selector
getNodeId, getNodeId, getObjectId, getObjectId, getObjectId, getObjectIds, getObjectIds, getObjectIdWithContext, getProperty, getProperty, getPropertyByObjectId, getPropertyDescriptor, matches, matches, matches, releaseObject, setProperty, setProperty
-
Method Details
-
getId
public java.lang.String getId() -
close
public void close()Close the this browser window- Specified by:
close
in interfacejava.lang.AutoCloseable
-
isConnected
public boolean isConnected() -
activate
public void activate()Activate this browser window -
addEventListener
UseSession#getListenerManager()
-
removeEventEventListener
UseSession#getListenerManager()
-
waitDocumentReady
waits until document is ready- Returns:
- this
-
waitDocumentReady
waits until document is ready- Parameters:
timeout
- the maximum time to wait in milliseconds- Returns:
- this
-
waitUntil
-
waitUntil
-
waitUntil
-
waitUntil
public boolean waitUntil(java.util.function.Predicate<Session> predicate, int timeout, int period, boolean log) -
navigate
-
navigateAndWait
-
navigateAndWait
-
enableConsoleLog
Redirects javascript console logs to slf4j- Returns:
- this
-
enableDetailLog
Redirects runtime logs (network, security, storage etc..) to slf4j- Returns:
- this
-
enableNetworkLog
Redirects network logs to slf4j- Returns:
- this
-
getThis
-
getFrameId
public java.lang.String getFrameId() -
captureScreenshot
public byte[] captureScreenshot()Capture page screenshot. -
captureScreenshot
public byte[] captureScreenshot(boolean hideScrollbar)Capture page screenshot.- Parameters:
hideScrollbar
- hides the scollbar
-
captureScreenshot
public byte[] captureScreenshot(boolean hideScrollbar, ImageFormat format, java.lang.Integer quality, Viewport clip, java.lang.Boolean fromSurface)Capture page screenshot.- Parameters:
hideScrollbar
- hides the scollbarformat
- Image compression format (defaults to png).quality
- Compression quality from range [0..100] (jpeg only).clip
- Capture the screenshot of a given region only.fromSurface
- Capture the screenshot from the surface, rather than the view. Defaults to true.
-
wait
Causes the current thread to wait until waiting time elapses.- Parameters:
timeout
- the maximum time to wait in milliseconds- Returns:
- this
- Throws:
CdpException
- if the session held by another thread at the time of invocation.
-
wait
Causes the current thread to wait until waiting time elapses.- Parameters:
timeout
- the maximum time to wait in milliseconds- Returns:
- this
- Throws:
CdpException
- if the session held by another thread at the time of invocation.
-
onTerminate
-
getCommand
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
registerJsFunction
public <T> T registerJsFunction(java.lang.Class<T> klass) -
getJsFunction
public <T> T getJsFunction(java.lang.Class<T> klass) -
getMajorVersion
public int getMajorVersion() -
getTargetId
public java.lang.String getTargetId() -
getBrowserContextId
public java.lang.String getBrowserContextId() -
getExecutionContextId
public java.lang.Integer getExecutionContextId() -
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-