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 voidactivate()Activate this browser windowvoidaddEventListener(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.voidclose()Close the this browser windowSessionenableConsoleLog()Redirects javascript console logs to slf4jSessionenableDetailLog()Redirects runtime logs (network, security, storage etc..) to slf4jSessionenableNetworkLog()Redirects network logs to slf4jbooleanequals(java.lang.Object obj)java.lang.StringgetBrowserContextId()CommandgetCommand()java.lang.IntegergetExecutionContextId()java.lang.StringgetFrameId()java.lang.StringgetId()<T> TgetJsFunction(java.lang.Class<T> klass)intgetMajorVersion()java.lang.StringgetTargetId()SessiongetThis()inthashCode()booleanisConnected()Sessionnavigate(java.lang.String url)SessionnavigateAndWait(java.lang.String url, WaitUntil condition)SessionnavigateAndWait(java.lang.String url, WaitUntil condition, int timeout)voidonTerminate(TerminateListener terminateListener)<T> TregisterJsFunction(java.lang.Class<T> klass)voidremoveEventEventListener(EventListener eventListener)UseSession#getListenerManager()java.lang.StringtoString()Sessionwait(int timeout)Causes the current thread to wait until waiting time elapses.Sessionwait(int timeout, boolean log)Causes the current thread to wait until waiting time elapses.SessionwaitDocumentReady()waits until document is readySessionwaitDocumentReady(int timeout)waits until document is readybooleanwaitUntil(java.util.function.Predicate<Session> predicate)booleanwaitUntil(java.util.function.Predicate<Session> predicate, int timeout)booleanwaitUntil(java.util.function.Predicate<Session> predicate, int timeout, int period)booleanwaitUntil(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, waitMethods 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, setValueMethods inherited from interface io.webfolder.cdp.session.JavaScript
callFunction, callFunction, callFunction, evaluate, getVariable, setVariableMethods inherited from interface io.webfolder.cdp.session.Keyboard
sendBackspace, sendDownArrow, sendEnter, sendEsc, sendKeyCode, sendKeys, sendLeftArrow, sendRightArrow, sendTab, sendUpArrowMethods inherited from interface io.webfolder.cdp.session.Navigator
back, clearCache, clearCookies, forward, getContent, getLocation, getPathname, getQueryString, getTitle, isDomReady, reload, setUserAgent, stopMethods 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:
closein 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin 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:
toStringin classjava.lang.Object
-