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
Modifier and Type Method Description <Error class: unknown class>addInitScriptAsync(String script)Adds a script which would be evaluated in one of the following scenarios: Whenever the page is navigated.
<Error class: unknown class>addBlockedURLsAsync(List<String> urls)Blocks URLs from loading. <Error class: unknown class>navigateToAsync(String url)Returns the main resource response. <Error class: unknown class>navigateToAsync(NavigateEntry entry)Returns the response of the main resource. <Error class: unknown class>currentUrlAsync()Returns a string representing the current URL that the browser is looking at. <Error class: unknown class>pageSourceAsync()Returns the source of the last loaded page. <Error class: unknown class>getCookiesAsync()<Error class: unknown class>bringToFrontAsync()Brings page to front (activates tab). <Error class: unknown class>waitForSelectorAsync(String selector)Returns when element specified by selector satisfies {@code state} option. <Error class: unknown class>waitForSelectorAsync(String selector, Long timeoutMillis)Returns when element specified by selector satisfies {@code state} option. <Error class: unknown class>waitForSelectorAsync(String selector, Duration timeout)<Error class: unknown class>waitForNavigationAsync(String oldUrl)<Error class: unknown class>waitForNavigationAsync(String oldUrl, Long timeoutMillis)<Error class: unknown class>waitForNavigationAsync(String oldUrl, Duration timeout)<Error class: unknown class>existsAsync(String selector)<Error class: unknown class>isVisibleAsync(String selector)<Error class: unknown class>isHiddenAsync(String selector)<Error class: unknown class>isCheckedAsync(String selector)<Error class: unknown class>typeAsync(String selector, String text)<Error class: unknown class>clickAsync(String selector, Integer count)<Error class: unknown class>clickMatchesAsync(String selector, String pattern, Integer count)<Error class: unknown class>clickMatchesAsync(String selector, String attrName, String pattern, Integer count)<Error class: unknown class>clickNthAnchorAsync(Integer n, String rootSelector)<Error class: unknown class>checkAsync(String selector)<Error class: unknown class>uncheckAsync(String selector)<Error class: unknown class>scrollToAsync(String selector)<Error class: unknown class>scrollDownAsync(Integer count)<Error class: unknown class>scrollUpAsync(Integer count)<Error class: unknown class>scrollToTopAsync()<Error class: unknown class>scrollToBottomAsync()<Error class: unknown class>mouseWheelDownAsync(Integer count, Double deltaX, Double deltaY, Long delayMillis)<Error class: unknown class>mouseWheelUpAsync(Integer count, Double deltaX, Double deltaY, Long delayMillis)<Error class: unknown class>moveMouseToAsync(Double x, Double y)<Error class: unknown class>dragAndDropAsync(String selector, Integer deltaX, Integer deltaY)<Error class: unknown class>outerHTMLAsync(String selector)CompletableFuture<String>selectFirstTextOrNullAsync(String selector)CompletableFuture<Optional<String>>selectFirstTextOptionalAsync(String selector)CompletableFuture<List<String>>selectTextAllAsync(String selector)CompletableFuture<String>selectFirstAttributeOrNullAsync(String selector, String attrName)CompletableFuture<Optional<String>>selectFirstAttributeOptionalAsync(String selector, String attrName)CompletableFuture<List<String>>selectAttributeAllAsync(String selector, String attrName)<Error class: unknown class>evaluateAsync(String expression)Executes JavaScript in the context of the currently selected frame or window. <Error class: unknown class>captureScreenshotAsync(String selector)This method scrolls element into view if needed, and then ake a screenshot of the element. <Error class: unknown class>captureScreenshotAsync(RectD rect)<Error class: unknown class>clickablePointAsync(String selector)Calculate the clickable point of an element located by selector. <Error class: unknown class>boundingBoxAsync(String selector)Return the bounding box of an element located by selector. <Error class: unknown class>newJsoupSessionAsync()Create a new Jsoup session with the last page's context, which means, the same headers and cookies. <Error class: unknown class>loadResourceAsync(String url)Load url as a resource without browser rendering, with the last page's context, which means, the same headers and cookies. <Error class: unknown class>pauseAsync()Force the page pauses all navigations and PENDING resource fetches. <Error class: unknown class>stopAsync()Force the page stop all navigations and RELEASES all resources. -
Methods inherited from class ai.platon.pulsar.skeleton.crawl.fetch.driver.WebDriver
addBlockedURLs, addInitScript, baseURI, boundingBox, bringToFront, captureScreenshot, captureScreenshot, captureScreenshot, chat, check, clearBrowserCookies, click, click, clickMatches, clickNthAnchor, clickTextMatches, clickablePoint, currentUrl, delay, delay, delay, deleteCookies, documentURI, dragAndDrop, evaluate, evaluate, evaluateDetail, evaluateValue, evaluateValue, evaluateValue, evaluateValueDetail, exists, extract, fill, focus, getBrowser, getBrowserType, getCookies, getData, getDelayPolicy, getFrames, getId, getNavigateEntry, getNavigateHistory, getOpener, getOutgoingPages, getParentSid, getTimeoutPolicy, goBack, goForward, hover, isChecked, isHidden, isVisible, jvm, loadJsoupResource, loadResource, mouseWheelDown, mouseWheelUp, moveMouseTo, moveMouseTo, nanoDOMTree, navigateTo, navigateTo, newJsoupSession, open, outerHTML, outerHTML, pageSource, pause, press, referrer, reload, scrollBy, scrollDown, scrollTo, scrollToBottom, scrollToMiddle, scrollToTop, scrollToViewport, scrollUp, selectAnchors, selectAttributeAll, selectAttributes, selectFirstAttributeOrNull, selectFirstPropertyValueOrNull, selectFirstTextOrNull, selectHyperlinks, selectImages, selectPropertyValueAll, selectTextAll, setAttribute, setAttributeAll, setNavigateEntry, setProperty, setPropertyAll, stop, textContent, title, type, uncheck, url, 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
<Error class: unknown class> 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
<Error class: unknown class> addBlockedURLsAsync(List<String> urls)
Blocks URLs from loading.
- Parameters:
urls- URL patterns to block.- Returns:
the new CompletableFuture
-
navigateToAsync
<Error class: unknown class> 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
<Error class: unknown class> 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
-
currentUrlAsync
<Error class: unknown class> 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
<Error class: unknown class> 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
<Error class: unknown class> getCookiesAsync()
-
bringToFrontAsync
<Error class: unknown class> bringToFrontAsync()
Brings page to front (activates tab).
-
waitForSelectorAsync
<Error class: unknown class> waitForSelectorAsync(String selector)
Returns when element specified by selector satisfies {@code state} option.
-
waitForSelectorAsync
<Error class: unknown class> waitForSelectorAsync(String selector, Long timeoutMillis)
Returns when element specified by selector satisfies {@code state} option. Returns the time remaining until timeout.
-
waitForSelectorAsync
<Error class: unknown class> waitForSelectorAsync(String selector, Duration timeout)
-
waitForNavigationAsync
<Error class: unknown class> waitForNavigationAsync(String oldUrl)
-
waitForNavigationAsync
<Error class: unknown class> waitForNavigationAsync(String oldUrl, Long timeoutMillis)
-
waitForNavigationAsync
<Error class: unknown class> waitForNavigationAsync(String oldUrl, Duration timeout)
-
existsAsync
<Error class: unknown class> existsAsync(String selector)
-
isVisibleAsync
<Error class: unknown class> isVisibleAsync(String selector)
-
isHiddenAsync
<Error class: unknown class> isHiddenAsync(String selector)
-
isCheckedAsync
<Error class: unknown class> isCheckedAsync(String selector)
-
clickAsync
<Error class: unknown class> clickAsync(String selector, Integer count)
-
clickMatchesAsync
<Error class: unknown class> clickMatchesAsync(String selector, String pattern, Integer count)
-
clickMatchesAsync
<Error class: unknown class> clickMatchesAsync(String selector, String attrName, String pattern, Integer count)
-
clickNthAnchorAsync
<Error class: unknown class> clickNthAnchorAsync(Integer n, String rootSelector)
-
checkAsync
<Error class: unknown class> checkAsync(String selector)
-
uncheckAsync
<Error class: unknown class> uncheckAsync(String selector)
-
scrollToAsync
<Error class: unknown class> scrollToAsync(String selector)
-
scrollDownAsync
<Error class: unknown class> scrollDownAsync(Integer count)
-
scrollUpAsync
<Error class: unknown class> scrollUpAsync(Integer count)
-
scrollToTopAsync
<Error class: unknown class> scrollToTopAsync()
-
scrollToBottomAsync
<Error class: unknown class> scrollToBottomAsync()
-
mouseWheelDownAsync
<Error class: unknown class> mouseWheelDownAsync(Integer count, Double deltaX, Double deltaY, Long delayMillis)
-
mouseWheelUpAsync
<Error class: unknown class> mouseWheelUpAsync(Integer count, Double deltaX, Double deltaY, Long delayMillis)
-
moveMouseToAsync
<Error class: unknown class> moveMouseToAsync(Double x, Double y)
-
dragAndDropAsync
<Error class: unknown class> dragAndDropAsync(String selector, Integer deltaX, Integer deltaY)
-
outerHTMLAsync
<Error class: unknown class> 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
<Error class: unknown class> 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
<Error class: unknown class> captureScreenshotAsync(String selector)
This method scrolls element into view if needed, and then ake a screenshot of the element.
-
captureScreenshotAsync
<Error class: unknown class> captureScreenshotAsync(RectD rect)
-
clickablePointAsync
<Error class: unknown class> 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
<Error class: unknown class> boundingBoxAsync(String selector)
Return the bounding box of an element located by selector. If the element does not exist, returns null.
-
newJsoupSessionAsync
<Error class: unknown class> newJsoupSessionAsync()
Create a new Jsoup session with the last page's context, which means, the same headers and cookies.
-
loadResourceAsync
<Error class: unknown class> 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
<Error class: unknown class> 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
<Error class: unknown class> 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.
-
-
-