Sulfide is a Selenide inspired library that can be used to simplify testing with Puppeteer.
Condition to test if an element collection has a certain number of elements on the page.
Void
Returns the message that will be passed to Jasmine when the condition is not met.
Name | Type | Description | |
---|---|---|---|
element |
SulfideElement
|
The element for which the condition will be tested |
String
The failure message for this condition
Returns the message that will be passed to Jasmine when the condition is not met.
Name | Type | Description | |
---|---|---|---|
element |
SulfideElement
|
The element for which the condition will be tested |
String
The failure message for this condition
Returns the message that will be passed to Jasmine when the condition is not met.
Name | Type | Description | |
---|---|---|---|
element |
SulfideElement
|
The element for which the condition will be tested |
String
The failure message for this condition
Returns the message that will be passed to Jasmine when the condition is not met.
Name | Type | Description | |
---|---|---|---|
element |
SulfideElement
|
The element for which the condition will be tested |
String
The failure message for this condition
Selects an element with the full text given
Name | Type | Description | |
---|---|---|---|
text |
String
|
The entire text of the element that should be selected. |
SulfideElement
SulfideElement wrapper of the element.
Selects an element that contains the text given
Name | Type | Description | |
---|---|---|---|
text |
String
|
The text that should be part of the text in the element that should be selected. |
SulfideElement
SulfideElement wrapper of the element.
Selects an element with the full text given
Name | Type | Description | |
---|---|---|---|
text |
String
|
The entire text of the element that should be selected. |
SulfideElement
SulfideElement wrapper of the element.
Selects an element that contains the text given
Name | Type | Description | |
---|---|---|---|
text |
String
|
The text that should be part of the text in the element that should be selected. |
SulfideElement
SulfideElement wrapper of the element.
Selects an element with the full text given
Name | Type | Description | |
---|---|---|---|
text |
String
|
The entire text of the element that should be selected. |
SulfideElement
SulfideElement wrapper of the element.
The url that will be used when launching the browser Note: This variable will not be updated when opening another page.
Void
Will keep references to the pages that are opened. The last one in this array will be the active page (i.e. the page on which actions are performed)
Void
The options used for NWJS apps. These are the default options of puppeteer without the --disable-extensions options because NWJS runs as an extension.
Void
Main function of Sulfide. Acts as an SulfideElement creator.
Name | Type | Description | |
---|---|---|---|
selector |
String
SulfideElement
|
CSS selector or xpath, used to create the SulfideElement, or a SulfideElement |
SulfideElement
the SulfideElement based on the passed selector or xpath
Set the configuration that Sulfide will use when launching a browser
Name | Type | Description | |
---|---|---|---|
config |
Object
|
The configuration object |
Object
The full configuration of Sulfide after adding the new config.
Can be used to sleep the execution of a async function. Usage:
await $.sleep(5000); // Sleep for 5 seconds
Name | Type | Description | |
---|---|---|---|
timeout |
number
|
The sleep time in milliseconds |
Promise
Resolves after timeout milliseconds
Creates the options object that is used to launch Chromium
Object
The options that are used to launch Chromium through Puppeteer
Opens a browser if necessary and navigates to the given URL.
Name | Type | Description | |
---|---|---|---|
url |
String
|
Url of the page that will be navigated to, or (for NWJS apps) the location (full path) of nw. |
Void
Closes the browser
Promise
Promise that will be resolved when the browser is closed
Returns the reference to the launched browser or null if no browser exists.
Browser
A reference to the browser instance
Gets the current page. Will create a new page if there are no pages and the browser has been launched.
Promise
Promise will resolve with a reference to the page.
Creates a new page when the browser has been launched
Promise
Resolves to a reference to the new page, or to null when no browser exists.
Returns all the pages opened in the browser.
Promise
Will resolve with an array of all opened pages
Sets the active page.
Name | Type | Description | |
---|---|---|---|
page |
Page
string
|
The page that should be activated. Can be a Page instance or the url of the page that should be activated. |
Page
The new page or null if the given page is not found.
A SulfideElement represents a DOM Element by a selector or an xpath. It can be used to run checks on DOM Element, e.g. if it exists.
Void
Constructor
Name | Type | Description | |
---|---|---|---|
selectorOrXPath |
String
|
A CSS selector or an xpath |
|
selectorDescription |
String
|
The description of the selector. This should be set by selectors when creating a SulfideElement |
Void
Finds the child of a SulfideElement. The child can be specified with a selector, an xpath, or a SulfideElement (created by a selector function)
Name | Type | Description | |
---|---|---|---|
selector |
string
SulfideElement
|
A css selector, an xpath or a SulfideElement created by a selector function. |
|
The |
string
|
name of the function that was called. This name will be used in the error message when an assertion fails. (Remember that there are aliases for this function) |
SulfideElement
A SulfideElement that represents the child.
Alias for the find method
Name | Type | Description | |
---|---|---|---|
selector |
string
SulfideElement
|
A css selector, and xpath or a SulfideElement created by a selector function. |
SulfideElement
A SulfideElement that represents the child.
A SulfideElementCollection represents a list of DOM Elements specified by a selector. It can be used to run checks on DOM Elements, e.g. if there exist a certain number of those elements.
Void