Class Browser
Browser can be created independent of an
actual browser instance as this is simply a logical representation of a
browser. Actual browser instances connect to BrowserService where
they are linked to Browser objects with the same BrowserId.
Once a BrowserSession connects and is online, the last navigation
event sent to the Browser will be forwarded to the browser instance.
Browser objects can represent actual browser instances running on
other nodes. If the nodes are powered off then the browser instances won't
be available but the Browser object will still be usable, it will
simply be offline. It's possible for a BrowserSession to be connected
to a Browser but still be offline depending on the implementation
of the BrowserSession. For example, the chrome adapter used to
control the chrome browser can be running while chrome itself is not. This
is reflected in the online flag.
Every Browser has a default host and port. These defaults will be
used any time a url is specified without a scheme (http://host:port). This
allows the Browser to be configured once at startup and all urls
without scheme data will automatically be sent to the default host. This
is an easy way to eliminate the need for application code to understand
how a cluster of nodes is wired up and how to get access to host/port
data. Instead, user logic can simply construct path-only urls and let
the Browser fill in the scheme. By default, all Browser
objects use the local node as the default host.
- Since:
- 1.0
- Version:
- 2023-02-26
-
Method Summary
Modifier and TypeMethodDescriptionvoidconnect(BrowserSession session) Called to link aBrowserSessionto theBrowser.voiddisconnect(BrowserSession session) Called to unlink aBrowserSessionfrom theBrowser.Return the default hostname to use for urls that don't specify a hostname.intReturn the default port to use for urls that don't specify a hostname/port.getId()voidLoads the specified URL in the browser.booleanisOnline()Return true if the actual browser is online and available for navigation.voidoffline()Called byBrowserSessionto indicate that it can no longer display content on a browser instance.voidonline()Called by aBrowserSessionto indicate that it can now display content on a browser instance.voidsetDefaultNode(NodeId nodeId) Set the default node to use for urls that don't specify a hostname.voidsetDefaultPort(int port) Set the default port to use for urls that don't specify a hostname/port.
-
Method Details
-
connect
Called to link aBrowserSessionto theBrowser. This should be followed by a call toonline()when the browser is actually available to show content.- Parameters:
session- the session to back this browser
-
disconnect
Called to unlink aBrowserSessionfrom theBrowser. Once called, theBrowserwill no longer be connected to an actual browser instance and thisBrowserobject will be marked offline.- Parameters:
session- the session to disconnect
-
online
public void online()Called by aBrowserSessionto indicate that it can now display content on a browser instance. This will force the most recent url to be sent to the session. -
offline
public void offline()Called byBrowserSessionto indicate that it can no longer display content on a browser instance. No navigation events will be sent to the session while it is offline. -
isOnline
public boolean isOnline()Return true if the actual browser is online and available for navigation. It is possible for aBrowserto be connected but be offline and unable to navigate. -
getDefaultHost
Return the default hostname to use for urls that don't specify a hostname. -
setDefaultNode
Set the default node to use for urls that don't specify a hostname. This leveragesNodeResolverServiceto resolve the default nodeId to an address.- Parameters:
nodeId- the node to point the browser to
-
getDefaultPort
public int getDefaultPort()Return the default port to use for urls that don't specify a hostname/port. -
setDefaultPort
public void setDefaultPort(int port) Set the default port to use for urls that don't specify a hostname/port.- Parameters:
port- the default port to use
-
goToUrl
Loads the specified URL in the browser. If the redirect flag is true, the navigation is performed through a redirect.- Parameters:
url- the URL to showredirect- if true, navigate using a redirect
-
getService
-
getId
-
getLastUrl
-