public interface Browser
The object which implements this interface represents the browser. It's public methods can be used for different purposes.
To open an URL in the browser, see these methods:
To handle the browser window, see these methods:
To get some information about the current window or tab, see these methods:
To manage storages, see these methods:
To handle downloaded files, use these methods:
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the browser window or tab.
|
Storage |
cookies()
Returns a
Storage instance which can be used to manipulate the cookies of the browser. |
File |
findDownloadedFile(Pattern pattern)
Returns a file which was downloaded with the browser earlier.
|
File |
findDownloadedFile(String fileName)
Returns a file which was downloaded with the browser earlier.
|
String |
getCompositeId()
Returns the composite ID of the current browser and tab.
|
BrowserKind |
getKind()
Returns an enumeration value which reflects the kind of the browser.
|
File |
getLatestDownloadedFile()
Returns the latest file from the browsers download directory.
|
String |
getPageSource()
Returns the HTML code of the current page.
|
String |
getURL()
Returns the current URL in the browser.
|
String |
getVersion()
Returns the version of the browser.
|
Storage |
localStorage()
Returns a
Storage instance which can be used to manipulate the local storage of the browser. |
void |
maximize()
Maximizes the size of the browser window to fit the borders of the current display.
|
void |
openURL(String url)
Opens the given URL in the browser.
|
default void |
openURL(URL url)
Opens the given URL in the browser.
|
void |
reload()
Reloads the current URL in the browser.
|
void |
resize(int width,
int height)
Sets the size of the browser window.
|
Screenshot |
saveScreenshot()
Save screenshot about the active window or tab.
|
Storage |
sessionStorage()
Returns a
Storage instance which can be used to manipulate the session storage of the browser. |
String getURL()
void openURL(String url)
http://localhost:8080/page,/page or index.html.If the URL is absolute, then it will be loaded in the browser.
If the URL is relative, then it will be appended to the value of the ibello.url.base configuration property,
and the result URL will be loaded into the browser.
url - relative or absolute URLNullPointerException - when the argument is nulldefault void openURL(URL url)
Opens the given URL in the browser.
url - the URL to setNullPointerException - when the argument is nullvoid reload()
void maximize()
Maximizes the size of the browser window to fit the borders of the current display.
void resize(int width,
int height)
width - the new width of the browser window, in pixelsheight - the new height of the browser window, in pixelsvoid close()
String getPageSource()
Screenshot saveScreenshot()
BrowserKind getKind()
String getVersion()
String getCompositeId()
Window annotation.
If the ID is empty then the browser is the default one.
If the ID starts with a colon then it represents a new tab in the default window.
If the ID contains a colon (but not starts with it), then it represents a tab in an additional browser window. The characters before the colon are assigned to the window.
If the ID does not contain a colon and it is not empty, then it represents the first tab of an additional window.
Storage sessionStorage()
Storage instance which can be used to manipulate the session storage of the browser.Storage localStorage()
Storage instance which can be used to manipulate the local storage of the browser.Storage cookies()
Storage instance which can be used to manipulate the cookies of the browser.File findDownloadedFile(String fileName)
null.
The method tries to find the file in the download directory of the browser.
In some cases browsers rename files because of name collision. The fileName
parameter of this method should be the original name of the file. The method will try to find out the new name.
fileName - the name of the downloaded filenullFile findDownloadedFile(Pattern pattern)
null.
The method tries to find the file in the download directory of the browser.
In some cases browsers rename files because of name collision. The pattern
parameter of this method should target the original name of the file. The method will try to find out the new name.
pattern - regular expression pattern for the name of the downloaded filenullFile getLatestDownloadedFile()
null.nullCreated by Kornél Simon, 2022