-
- All Implemented Interfaces:
-
ai.platon.pulsar.crawl.fetch.driver.WebDriver,java.io.Closeable,java.lang.AutoCloseable,kotlin.Comparable
public final class ChromeDevtoolsDriver extends AbstractWebDriver
-
-
Field Summary
Fields Modifier and Type Field Description private final BrowserTypebrowserTypeprivate final IntegeropenSequenceprivate final DurationchromeTabTimeoutprivate final StringuserAgentprivate final BooleanenableUrlBlockingprivate final BooleanisSPAprivate InstantlastActiveTimeprivate final BooleanisGoneprivate final BooleanisActiveprivate final StringtabIdprivate final RemoteDevToolsimplementationprivate final StringsessionIdprivate final ChromeDevtoolsBrowserbrowserprivate final BrowserInstanceIdbrowserIdprivate final Function1<String, Long>delayPolicyprivate final Integeridprivate DurationidleTimeoutprivate final BooleanisCanceledprivate final BooleanisCrashedprivate final BooleanisFreeprivate final BooleanisIdleprivate final BooleanisMockedPageSourceprivate final BooleanisNotWorkingprivate final BooleanisQuitprivate final BooleanisRetiredprivate final BooleanisWorkingprivate final Stringnameprivate NavigateEntrynavigateEntryprivate final List<NavigateEntry>navigateHistoryprivate final AtomicReference<WebDriver.Status>statusprivate final BooleansupportJavascriptprivate DurationwaitForTimeout
-
Constructor Summary
Constructors Constructor Description ChromeDevtoolsDriver(ChromeTab chromeTab, RemoteDevTools devTools, BrowserSettings browserSettings, ChromeDevtoolsBrowser browser)
-
Method Summary
Modifier and Type Method Description BrowserTypegetBrowserType()final IntegergetOpenSequence()final DurationgetChromeTabTimeout()final StringgetUserAgent()final BooleangetEnableUrlBlocking()final BooleangetIsSPA()InstantgetLastActiveTime()UnitsetLastActiveTime(Instant lastActiveTime)final BooleangetIsGone()final BooleangetIsActive()final StringgetTabId()final RemoteDevToolsgetImplementation()StringgetSessionId()ChromeDevtoolsBrowsergetBrowser()BrowserInstanceIdgetBrowserId()Function1<String, Long>getDelayPolicy()IntegergetId()DurationgetIdleTimeout()UnitsetIdleTimeout(Duration idleTimeout)BooleangetIsCanceled()BooleangetIsCrashed()BooleangetIsFree()BooleangetIsIdle()BooleangetIsMockedPageSource()final BooleangetIsNotWorking()BooleangetIsQuit()BooleangetIsRetired()BooleangetIsWorking()StringgetName()NavigateEntrygetNavigateEntry()UnitsetNavigateEntry(NavigateEntry navigateEntry)List<NavigateEntry>getNavigateHistory()AtomicReference<WebDriver.Status>getStatus()BooleangetSupportJavascript()DurationgetWaitForTimeout()UnitsetWaitForTimeout(Duration waitForTimeout)UnitaddInitScript(String script)UnitsetTimeouts(BrowserSettings browserSettings)UnitnavigateTo(NavigateEntry entry)Map<String, Object>mainRequestHeaders()List<Map<String, String>>mainRequestCookies()List<Map<String, String>>getCookies()Unitstop()Force the page stop all navigations and releases all resources. UnitstopLoading()Force the page stop all navigations and pending resource fetches. Unitterminate()Force the page stop all navigations and releases all resources. Objectevaluate(String expression)Evaluate a javascript expression in the browser. StringcurrentUrl()Booleanexists(String selector)Booleanvisible(String selector)LongwaitForSelector(String selector, Duration timeout)Wait until selector for timeout at most LongwaitForNavigation(Duration timeout)UnitmouseWheelDown(Integer count, Double deltaX, Double deltaY, Long delayMillis)UnitmouseWheelUp(Integer count, Double deltaX, Double deltaY, Long delayMillis)UnitmoveMouseTo(Double x, Double y)Unitclick(String selector, Integer count)This method fetches an element with selector, scrolls it into view if needed, and then uses {@link Mouse} to click in the center of the element.UnitclickMatches(String selector, String pattern, Integer count)UnitclickMatches(String selector, String attrName, String pattern, Integer count)Unittype(String selector, String text)UnitscrollTo(String selector)UnitdragAndDrop(String selector, Integer deltaX, Integer deltaY)PointDclickablePoint(String selector)RectDboundingBox(String selector)StringcaptureScreenshot(String selector)This method scrolls element into view if needed, and then uses {@link page.captureScreenshot} to take a screenshot of the element. StringcaptureScreenshot(RectD clip)StringpageSource()UnitbringToFront()StringtoString()Unitquit()Quit the browser instance UnitawaitTermination()Unitclose()Close the tab hold by this driver -
Methods inherited from class ai.platon.pulsar.protocol.browser.driver.cdt.ChromeDevtoolsDriver
allAttrs, allTexts, cancel, clickNthAnchor, compareTo, equals, evaluateSilently, firstAttr, firstText, free, hashCode, loadResource, navigateTo, newSession, outerHTML, retire, scrollDown, scrollToBottom, scrollToMiddle, scrollToTop, scrollUp, startWork, waitForNavigation, waitForNavigation, waitForSelector, waitForSelector -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ChromeDevtoolsDriver
ChromeDevtoolsDriver(ChromeTab chromeTab, RemoteDevTools devTools, BrowserSettings browserSettings, ChromeDevtoolsBrowser browser)
-
-
Method Detail
-
getBrowserType
BrowserType getBrowserType()
-
getOpenSequence
final Integer getOpenSequence()
-
getChromeTabTimeout
final Duration getChromeTabTimeout()
-
getUserAgent
final String getUserAgent()
-
getEnableUrlBlocking
final Boolean getEnableUrlBlocking()
-
getLastActiveTime
Instant getLastActiveTime()
-
setLastActiveTime
Unit setLastActiveTime(Instant lastActiveTime)
-
getIsActive
final Boolean getIsActive()
-
getImplementation
final RemoteDevTools getImplementation()
-
getSessionId
String getSessionId()
-
getBrowser
ChromeDevtoolsBrowser getBrowser()
-
getBrowserId
BrowserInstanceId getBrowserId()
-
getDelayPolicy
Function1<String, Long> getDelayPolicy()
-
getIdleTimeout
Duration getIdleTimeout()
-
setIdleTimeout
Unit setIdleTimeout(Duration idleTimeout)
-
getIsCanceled
Boolean getIsCanceled()
-
getIsCrashed
Boolean getIsCrashed()
-
getIsMockedPageSource
Boolean getIsMockedPageSource()
-
getIsNotWorking
final Boolean getIsNotWorking()
-
getIsRetired
Boolean getIsRetired()
-
getIsWorking
Boolean getIsWorking()
-
getNavigateEntry
NavigateEntry getNavigateEntry()
-
setNavigateEntry
Unit setNavigateEntry(NavigateEntry navigateEntry)
-
getNavigateHistory
List<NavigateEntry> getNavigateHistory()
-
getStatus
AtomicReference<WebDriver.Status> getStatus()
-
getSupportJavascript
Boolean getSupportJavascript()
-
getWaitForTimeout
Duration getWaitForTimeout()
-
setWaitForTimeout
Unit setWaitForTimeout(Duration waitForTimeout)
-
addInitScript
Unit addInitScript(String script)
-
setTimeouts
Unit setTimeouts(BrowserSettings browserSettings)
-
navigateTo
Unit navigateTo(NavigateEntry entry)
-
mainRequestHeaders
Map<String, Object> mainRequestHeaders()
-
mainRequestCookies
List<Map<String, String>> mainRequestCookies()
-
getCookies
List<Map<String, String>> getCookies()
-
stopLoading
Unit stopLoading()
Force the page stop all navigations and pending resource fetches.
-
evaluate
Object evaluate(String expression)
Evaluate a javascript expression in the browser. The expression should be a single line.
-
currentUrl
String currentUrl()
-
waitForSelector
Long waitForSelector(String selector, Duration timeout)
-
waitForNavigation
Long waitForNavigation(Duration timeout)
-
moveMouseTo
Unit moveMouseTo(Double x, Double y)
-
click
Unit click(String selector, Integer count)
This method fetches an element with
selector, scrolls it into view if needed, and then uses {@link Mouse} to click in the center of the element. If there's no element matchingselector, the method do not click anything.- Parameters:
selector-A
selectorto search for element to click. If there are multiple elements satisfying theselector, the first will be clicked
count-Click count
-
clickMatches
Unit clickMatches(String selector, String pattern, Integer count)
-
dragAndDrop
Unit dragAndDrop(String selector, Integer deltaX, Integer deltaY)
-
clickablePoint
PointD clickablePoint(String selector)
-
boundingBox
RectD boundingBox(String selector)
-
captureScreenshot
String captureScreenshot(String selector)
This method scrolls element into view if needed, and then uses {@link page.captureScreenshot} to take a screenshot of the element. If the element is detached from DOM, the method throws an error.
-
captureScreenshot
String captureScreenshot(RectD clip)
-
pageSource
String pageSource()
-
bringToFront
Unit bringToFront()
-
awaitTermination
Unit awaitTermination()
-
-
-
-