Class AbstractJvmWebDriver
-
- 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
public abstract class AbstractJvmWebDriver implements JvmWebDriver, WebDriver
-
-
Field Summary
Fields Modifier and Type Field Description private final Integeridprivate final IntegerparentSidprivate final Browserbrowserprivate final List<WebDriver>framesprivate final WebDriveropenerprivate final Set<WebDriver>outgoingPagesprivate final BrowserTypebrowserTypeprivate NavigateEntrynavigateEntryprivate final NavigateHistorynavigateHistoryprivate final Map<String, Object>dataprivate final Map<String, IntRange>delayPolicyprivate final Map<String, Duration>timeoutPolicy
-
Constructor Summary
Constructors Constructor Description AbstractJvmWebDriver()
-
Method Summary
-
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.WebDriver
addBlockedURLs, addInitScript, addProbabilityBlockedURLs, baseURI, boundingBox, bringToFront, captureScreenshot, captureScreenshot, captureScreenshot, chat, check, clearBrowserCookies, click, clickMatches, clickNthAnchor, clickTextMatches, clickablePoint, currentUrl, delay, delay, delay, deleteCookies, deleteCookies, documentURI, dragAndDrop, evaluate, evaluate, evaluateDetail, evaluateValue, evaluateValue, evaluateValueDetail, exists, fill, focus, getBrowser, getBrowserType, getCookies, getData, getDelayPolicy, getFrames, getId, getNavigateEntry, getNavigateHistory, getOpener, getOutgoingPages, getParentSid, getTimeoutPolicy, instruct, isChecked, isHidden, isVisible, jvm, loadJsoupResource, loadResource, mouseWheelDown, mouseWheelUp, moveMouseTo, moveMouseTo, navigateTo, navigateTo, newJsoupSession, open, outerHTML, outerHTML, pageSource, pause, press, referrer, scrollDown, scrollTo, scrollToBottom, scrollToMiddle, scrollToScreen, scrollToTop, scrollUp, selectAnchors, selectAttributeAll, selectAttributes, selectFirstAttributeOrNull, selectFirstPropertyValueOrNull, selectFirstTextOrNull, selectHyperlinks, selectImages, selectPropertyValueAll, selectTextAll, setAttribute, setAttributeAll, setNavigateEntry, setProperty, setPropertyAll, setTimeouts, stop, type, uncheck, url, visible, waitForNavigation, waitForNavigation, waitForNavigation, waitForPage, waitForSelector, waitForSelector, waitForSelector, waitForSelector, waitForSelector, waitForSelector, waitUntil, waitUntil, waitUntil -
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.JvmWebDriver
clickAsync, clickMatchesAsync, clickMatchesAsync -
Methods inherited from class java.io.Closeable
close -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
addInitScriptAsync
CompletableFuture<Unit> addInitScriptAsync(String script)
Adds a script which would be evaluated in one of the following scenarios:
Whenever the page is navigated.
The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed Math.random.
- Parameters:
script- Javascript source code to add.
-
addBlockedURLsAsync
CompletableFuture<Unit> addBlockedURLsAsync(List<String> urls)
Blocks URLs from loading.
- Parameters:
urls- URL patterns to block.- Returns:
the new CompletableFuture
-
navigateToAsync
CompletableFuture<Unit> navigateToAsync(String url)
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the first non-redirect response.
- Parameters:
url- URL to navigate page to.- Returns:
the new CompletableFuture
-
navigateToAsync
CompletableFuture<Unit> navigateToAsync(NavigateEntry entry)
Returns the response of the main resource. In case of multiple redirects, the navigation will resolve with the first non-redirect response.
- Parameters:
entry- NavigateEntry to navigate page to.- Returns:
the new CompletableFuture
-
setTimeoutsAsync
CompletableFuture<Unit> setTimeoutsAsync(BrowserSettings browserSettings)
-
currentUrlAsync
CompletableFuture<String> currentUrlAsync()
Returns a string representing the current URL that the browser is looking at.
- Returns:
The URL of the page currently loaded in the browser
-
pageSourceAsync
CompletableFuture<String> pageSourceAsync()
Returns the source of the last loaded page. If the page has been modified after loading (for example, by Javascript) there is no guarantee that the returned text is that of the modified page.
- Returns:
The source of the current page
-
getCookiesAsync
CompletableFuture<List<Map<String, String>>> getCookiesAsync()
-
bringToFrontAsync
CompletableFuture<Unit> bringToFrontAsync()
Brings page to front (activates tab).
-
waitForSelectorAsync
CompletableFuture<Duration> waitForSelectorAsync(String selector)
Returns when element specified by selector satisfies {@code state} option.
-
waitForSelectorAsync
CompletableFuture<Long> waitForSelectorAsync(String selector, Long timeoutMillis)
Returns when element specified by selector satisfies {@code state} option. Returns the time remaining until timeout.
-
waitForSelectorAsync
CompletableFuture<Duration> waitForSelectorAsync(String selector, Duration timeout)
-
waitForNavigationAsync
CompletableFuture<Duration> waitForNavigationAsync(String oldUrl)
-
waitForNavigationAsync
CompletableFuture<Long> waitForNavigationAsync(String oldUrl, Long timeoutMillis)
-
waitForNavigationAsync
CompletableFuture<Duration> waitForNavigationAsync(String oldUrl, Duration timeout)
-
existsAsync
CompletableFuture<Boolean> existsAsync(String selector)
-
isVisibleAsync
CompletableFuture<Boolean> isVisibleAsync(String selector)
-
visibleAsync
CompletableFuture<Boolean> visibleAsync(String selector)
-
isHiddenAsync
CompletableFuture<Boolean> isHiddenAsync(String selector)
-
isCheckedAsync
CompletableFuture<Boolean> isCheckedAsync(String selector)
-
typeAsync
CompletableFuture<Unit> typeAsync(String selector, String text)
-
clickAsync
CompletableFuture<Unit> clickAsync(String selector, Integer count)
-
clickMatchesAsync
CompletableFuture<Unit> clickMatchesAsync(String selector, String pattern, Integer count)
-
clickMatchesAsync
CompletableFuture<Unit> clickMatchesAsync(String selector, String attrName, String pattern, Integer count)
-
clickNthAnchorAsync
CompletableFuture<String> clickNthAnchorAsync(Integer n, String rootSelector)
-
checkAsync
CompletableFuture<Unit> checkAsync(String selector)
-
uncheckAsync
CompletableFuture<Unit> uncheckAsync(String selector)
-
scrollToAsync
CompletableFuture<Unit> scrollToAsync(String selector)
-
scrollDownAsync
CompletableFuture<Unit> scrollDownAsync(Integer count)
-
scrollUpAsync
CompletableFuture<Unit> scrollUpAsync(Integer count)
-
scrollToTopAsync
CompletableFuture<Unit> scrollToTopAsync()
-
scrollToBottomAsync
CompletableFuture<Unit> scrollToBottomAsync()
-
mouseWheelDownAsync
CompletableFuture<Unit> mouseWheelDownAsync(Integer count, Double deltaX, Double deltaY, Long delayMillis)
-
mouseWheelUpAsync
CompletableFuture<Unit> mouseWheelUpAsync(Integer count, Double deltaX, Double deltaY, Long delayMillis)
-
moveMouseToAsync
CompletableFuture<Unit> moveMouseToAsync(Double x, Double y)
-
dragAndDropAsync
CompletableFuture<Unit> dragAndDropAsync(String selector, Integer deltaX, Integer deltaY)
-
outerHTMLAsync
CompletableFuture<String> outerHTMLAsync(String selector)
-
selectFirstTextOrNullAsync
CompletableFuture<String> selectFirstTextOrNullAsync(String selector)
-
selectFirstTextOptionalAsync
CompletableFuture<Optional<String>> selectFirstTextOptionalAsync(String selector)
-
selectTextAllAsync
CompletableFuture<List<String>> selectTextAllAsync(String selector)
-
selectFirstAttributeOrNullAsync
CompletableFuture<String> selectFirstAttributeOrNullAsync(String selector, String attrName)
-
selectFirstAttributeOptionalAsync
CompletableFuture<Optional<String>> selectFirstAttributeOptionalAsync(String selector, String attrName)
-
selectAttributeAllAsync
CompletableFuture<List<String>> selectAttributeAllAsync(String selector, String attrName)
-
evaluateAsync
CompletableFuture<Object> evaluateAsync(String expression)
Executes JavaScript in the context of the currently selected frame or window. The script fragment provided will be executed as the body of an anonymous function.
- Parameters:
expression- Javascript expression to evaluate- Returns:
Remote object value in case of primitive values or JSON values (if it was requested).
-
captureScreenshotAsync
CompletableFuture<String> captureScreenshotAsync(String selector)
This method scrolls element into view if needed, and then ake a screenshot of the element.
-
captureScreenshotAsync
CompletableFuture<String> captureScreenshotAsync(RectD rect)
-
clickablePointAsync
CompletableFuture<PointD> clickablePointAsync(String selector)
Calculate the clickable point of an element located by selector. If the element does not exist, or is not clickable, returns null.
-
boundingBoxAsync
CompletableFuture<RectD> boundingBoxAsync(String selector)
Return the bounding box of an element located by selector. If the element does not exist, returns null.
-
newJsoupSessionAsync
CompletableFuture<Connection> newJsoupSessionAsync()
Create a new Jsoup session with the last page's context, which means, the same headers and cookies.
-
loadResourceAsync
CompletableFuture<NetworkResourceResponse> loadResourceAsync(String url)
Load url as a resource without browser rendering, with the last page's context, which means, the same headers and cookies.
-
pauseAsync
CompletableFuture<Unit> pauseAsync()
Force the page pauses all navigations and PENDING resource fetches. If the page loading stops, the user can still interact with the page, and therefore resources can continue to load.
-
stopAsync
CompletableFuture<Unit> stopAsync()
Force the page stop all navigations and RELEASES all resources. Interaction with the stop page results in undefined behavior and the results should not be trusted.
If a web driver stops, it can later be used to visit new pages.
-
-
-
-