Class ChromeDevtoolsDriver
-
- All Implemented Interfaces:
-
ai.platon.pulsar.skeleton.crawl.fetch.driver.JvmWebDriver,ai.platon.pulsar.skeleton.crawl.fetch.driver.WebDriver,java.io.Closeable,java.lang.AutoCloseable,kotlin.Comparable
public final class ChromeDevtoolsDriver extends AbstractWebDriver
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classChromeDevtoolsDriver.Companion
-
Field Summary
Fields Modifier and Type Field Description private final BrowserTypebrowserTypeprivate final FloatresourceBlockProbabilityprivate final List<String>blockedURLsprivate final List<String>probabilisticBlockedURLsprivate final BooleanisGoneprivate final BooleanisActiveprivate final RemoteDevToolsimplementationprivate final ChromeTabchromeTabprivate final RemoteDevToolsdevToolsprivate final ChromeDevtoolsBrowserbrowserprivate final Map<String, Object>dataprivate final Map<String, IntRange>delayPolicyprivate final List<WebDriver>framesprivate final Integeridprivate DurationidleTimeoutprivate final BooleanisCanceledprivate final BooleanisCrashedprivate final BooleanisIdleprivate final BooleanisInitprivate final BooleanisMockedPageSourceprivate final BooleanisQuitprivate final BooleanisReadyprivate BooleanisRecoveredprivate final BooleanisRetiredprivate BooleanisReusedprivate final BooleanisWorkingprivate InstantlastActiveTimeprivate final List<Map<String, String>>mainRequestCookiesprivate final Map<String, Object>mainRequestHeadersprivate final Map<String, Object>mainResponseHeadersprivate final IntegermainResponseStatusprivate final StringmainResponseStatusTextprivate final Stringnameprivate NavigateEntrynavigateEntryprivate final NavigateHistorynavigateHistoryprivate WebDriveropenerprivate final Set<WebDriver>outgoingPagesprivate final BooleansupportJavascriptprivate final Map<String, Duration>timeoutPolicypublic final static ChromeDevtoolsDriver.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description ChromeDevtoolsDriver(ChromeTab chromeTab, RemoteDevTools devTools, BrowserSettings browserSettings, ChromeDevtoolsBrowser browser)
-
Method Summary
Modifier and Type Method Description BrowserTypegetBrowserType()final FloatgetResourceBlockProbability()final List<String>getBlockedURLs()final List<String>getProbabilisticBlockedURLs()final BooleanisGone()final BooleanisActive()final RemoteDevToolsgetImplementation()final ChromeTabgetChromeTab()final RemoteDevToolsgetDevTools()ChromeDevtoolsBrowsergetBrowser()UnitaddInitScript(String script)UnitaddBlockedURLs(List<String> urlPatterns)UnitaddProbabilityBlockedURLs(List<String> urlPatterns)UnitsetTimeouts(BrowserSettings browserSettings)UnitnavigateTo(NavigateEntry entry)List<Map<String, String>>getCookies()UnitdeleteCookies(String name)UnitdeleteCookies(String name, String url, String domain, String path)UnitclearBrowserCookies()StringselectFirstAttributeOrNull(String selector, String attrName)Objectevaluate(String expression)JsEvaluationevaluateDetail(String expression)StringcurrentUrl()Booleanexists(String selector)DurationwaitForSelector(String selector, Duration timeout, SuspendFunction0<Unit> action)Wait until selector for timeout at most DurationwaitForNavigation(String oldUrl, Duration timeout)WebDriverwaitForPage(String url, Duration timeout)DurationwaitUntil(Duration timeout, SuspendFunction0<Boolean> predicate)UnitmouseWheelDown(Integer count, Double deltaX, Double deltaY, Long delayMillis)UnitmouseWheelUp(Integer count, Double deltaX, Double deltaY, Long delayMillis)UnitmoveMouseTo(Double x, Double y)TODO: test is required UnitmoveMouseTo(String selector, Integer deltaX, Integer deltaY)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.Unitfocus(String selector)Unittype(String selector, String text)Unitfill(String selector, String text)Unitpress(String selector, String key)UnitscrollTo(String selector)UnitdragAndDrop(String selector, Integer deltaX, Integer deltaY)StringouterHTML()StringouterHTML(String selector)PointDclickablePoint(String selector)RectDboundingBox(String selector)StringcaptureScreenshot()This method scrolls element into view if needed, and then uses {@link page.captureScreenshot} to take a screenshot of the element. 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 rect)StringpageSource()UnitbringToFront()UnitawaitTermination()NetworkResourceResponseloadResource(String url)Unitclose()Close the tab hold by this driver. final UnitdoClose()Unitpause()Unitstop()StringtoString()final UnitenableAPIAgents()-
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.AbstractWebDriver
baseURI, cancel, check, clickMatches, clickNthAnchor, clickTextMatches, compareTo, documentURI, equals, evaluate, free, getData, getDelayPolicy, getFrames, getId, getIdleTimeout, getLastActiveTime, getMainRequestCookies, getMainRequestHeaders, getMainResponseHeaders, getMainResponseStatus, getMainResponseStatusText, getName, getNavigateEntry, getNavigateHistory, getOpener, getOutgoingPages, getSupportJavascript, getTimeoutPolicy, hashCode, isCanceled, isChecked, isCrashed, isIdle, isInit, isMockedPageSource, isQuit, isReady, isRecovered, isRetired, isReused, isVisible, isWorking, jvm, loadJsoupResource, navigateTo, newJsoupSession, randomDelayMillis, referrer, retire, scrollDown, scrollToBottom, scrollToMiddle, scrollToMiddle, scrollToTop, scrollUp, selectAnchors, selectAttributeAll, selectAttributes, selectFirstTextOrNull, selectHyperlinks, selectImages, selectTextAll, setAttribute, setAttributeAll, setIdleTimeout, setLastActiveTime, setNavigateEntry, setOpener, setRecovered, setReused, startWork, terminate, timeout, uncheck, url, waitForNavigation, waitForSelector, waitForSelector, waitUntil -
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.WebDriver
allTexts, firstText, isHidden, selectTexts, visible, waitForNavigation, waitForSelector, waitForSelector, waitForSelector, waitUntil -
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.AbstractJvmWebDriver
addBlockedURLsAsync, addInitScriptAsync, boundingBoxAsync, bringToFrontAsync, captureScreenshotAsync, captureScreenshotAsync, checkAsync, clickAsync, clickMatchesAsync, clickMatchesAsync, clickNthAnchorAsync, clickablePointAsync, currentUrlAsync, dragAndDropAsync, evaluateAsync, existsAsync, getCookiesAsync, isCheckedAsync, isHiddenAsync, isVisibleAsync, loadResourceAsync, mouseWheelDownAsync, mouseWheelUpAsync, moveMouseToAsync, navigateToAsync, navigateToAsync, newJsoupSessionAsync, outerHTMLAsync, pageSourceAsync, pauseAsync, scrollDownAsync, scrollToAsync, scrollToBottomAsync, scrollToMiddleAsync, scrollToTopAsync, scrollUpAsync, selectAttributeAllAsync, selectFirstAttributeOptionalAsync, selectFirstAttributeOrNullAsync, selectFirstTextOptionalAsync, selectFirstTextOrNullAsync, selectTextAllAsync, setTimeoutsAsync, stopAsync, typeAsync, uncheckAsync, visibleAsync, waitForNavigationAsync, waitForNavigationAsync, waitForNavigationAsync, waitForSelectorAsync, waitForSelectorAsync, waitForSelectorAsync -
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.JvmWebDriver
clickAsync, clickMatchesAsync, clickMatchesAsync -
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()
-
getResourceBlockProbability
final Float getResourceBlockProbability()
-
getBlockedURLs
final List<String> getBlockedURLs()
-
getProbabilisticBlockedURLs
final List<String> getProbabilisticBlockedURLs()
-
getImplementation
final RemoteDevTools getImplementation()
-
getChromeTab
final ChromeTab getChromeTab()
-
getDevTools
final RemoteDevTools getDevTools()
-
getBrowser
ChromeDevtoolsBrowser getBrowser()
-
addInitScript
Unit addInitScript(String script)
-
addBlockedURLs
Unit addBlockedURLs(List<String> urlPatterns)
-
addProbabilityBlockedURLs
Unit addProbabilityBlockedURLs(List<String> urlPatterns)
-
setTimeouts
Unit setTimeouts(BrowserSettings browserSettings)
-
navigateTo
Unit navigateTo(NavigateEntry entry)
-
getCookies
List<Map<String, String>> getCookies()
-
deleteCookies
Unit deleteCookies(String name)
-
clearBrowserCookies
Unit clearBrowserCookies()
-
selectFirstAttributeOrNull
String selectFirstAttributeOrNull(String selector, String attrName)
-
evaluateDetail
JsEvaluation evaluateDetail(String expression)
-
currentUrl
String currentUrl()
-
waitForSelector
Duration waitForSelector(String selector, Duration timeout, SuspendFunction0<Unit> action)
-
waitForNavigation
Duration waitForNavigation(String oldUrl, Duration timeout)
-
waitForPage
WebDriver waitForPage(String url, Duration timeout)
-
waitUntil
Duration waitUntil(Duration timeout, SuspendFunction0<Boolean> predicate)
-
moveMouseTo
Unit moveMouseTo(Double x, Double y)
TODO: test is required
-
moveMouseTo
Unit moveMouseTo(String selector, Integer deltaX, Integer deltaY)
-
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
-
dragAndDrop
Unit dragAndDrop(String selector, Integer deltaX, Integer deltaY)
-
clickablePoint
PointD clickablePoint(String selector)
-
boundingBox
RectD boundingBox(String selector)
-
captureScreenshot
String captureScreenshot()
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(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 rect)
-
pageSource
String pageSource()
-
bringToFront
Unit bringToFront()
-
awaitTermination
Unit awaitTermination()
-
loadResource
NetworkResourceResponse loadResource(String url)
-
enableAPIAgents
final Unit enableAPIAgents()
-
-
-
-