5 Selenium Page And Session Reference - essenius/FitNesseFitSharpSelenium GitHub Wiki

These are the available page and session handling functions in the Selenium script fixture:

Page Actions

Close Page
Description: Closes the current browser page. Does not close the browser itself.
In: -
Out: whether the close succeeded (true/false)
Example(s): | close page |
Press Key Code
Description: Press a key on an Android via a keycode (number or field name). Returns false if not run on an Android or the keycode is not recognized
In: key code
Out: Success? (true/false)
Example(s): | press key code | home |
Reload Page
Description: Reload the current page
In: -
Out: success? (true/false)
Example(s): | Reload page |
Scroll
Description: Scroll in a direction. Implemented as a swipe on mobile devices.
In: Up/Down/Left/Right
Out: success? (true/false)
Example(s): | Scroll | Right |
Switch To Default Context
Description: Switch to the root html context (i.e. leave frame context)
In: -
Out: true if successful, false if not
Example(s): | switch to default context |
Switch To Frame
Description: Switch context to a frame in the current html page
In: frame locator
Out: true if successful, false if not
Example(s): | switch to frame | iframe1 |

Page Inquiry

Length Of Page Source
Description: Return the length of the HTML source
In: -
Out: number of characters in the HTML source
Example(s): | check | length of html source | >100 |
Page Source
Description: Return the page source of the current page in context
In: -
Out: page source in the current context
Example(s): | show | page source |
Screenshot
Description: Take a screenshot
In: -
Out: rendered image in tag
Example(s): | Show | Screenshot |
Note(s): When using from FitNesse running as a service, this may return a black square (no interaction with the desktop)
Screenshot Object
Description: Take a screenshot
In: -
Out: object which can be assigned to a symbol
Example(s): | $screenshot= | Screenshot Object |
Note(s): When using from FitNesse running as a service, this may return a black square
Text Exists [Ignoring Case]
Description: Check whether a certain text exists on the page. Case insensitive search
In: text to search for
Out: true if found on the page, false if not
Example(s): | ensure | text | Software Engineering | exists |
| ensure | text | software engineering | exists ignoring case |
Title
Description: Get the title of the current page
In: -
Out: page title, empty string if no page loaded
Example(s): | check | Title | =~/(?i)(Cheese) โ€“ Google/ |
Url
Description: Return the URL of the current page
In: -
Out: URL, or null if no page loaded
Example(s): | show | Url |
Wait For Page Source to Change
Description: Wait for the page source to change. Can happen with dynamic pages
In: -
Out: Whether page has changed before the timeout (true/false)
Example(s): | Wait For Page Source to Change |
Wait For Page To Load
Description: Waits for a page to load, using default timeout
In: -
Out: Whether page loading succeeded (true/false)
Example(s): | ensure | Wait For Page To Load |
Wait For Text [ Ignoring Case ]
Description: Waits for a certain text to be present (case sensitive search). Case insensitive search
In: text to search
Out: whether or not the text was found (true/false)
Example(s): | wait for text | I am watching |
| wait for text | I am watching | ignoring case |
Wait Until Page Source Is Larger Than
Description: Wait until the page source has the specified minimum length. Useful when pages are built up dynamically and asynchronously.
In: the minimum page size in characters
Out: whether or not the page source has the minimum length before timeout (true/false)
Example(s): | Wait Until Page Source Is Larger Than | 100 |
Wait Until Title Matches
Description: Wait for a title to appear, using a regular expression to search
In: regular expression to match
Out: true if match was found before the timeout, false if not.
Example(s): | wait until title matches | ^(?i)(Cheese) |

Sesssion Actions

Close
Description: Closes this browser session
In: -
Out: whether the close succeeded (true/false)
Example(s): | close |
Exception On Deprecated Functions
Description: If set to true, the use of a deprecated function will cause a warning exception. If false, it wonโ€™t. Default is false.
In: true/false
Out: -
Example(s): | Set Exception for Deprecated Functions | true |
Implicit Wait Seconds
Description: Set the number of seconds for implicit wait (0 = disable)
In: number of seconds
Example(s): | Implicit wait | 5 | seconds |
Integrated authentication domain
Description: Set the domain where integrated authentication is attempted (used by Firefox)
In: domain name
Example(s): | Integrated authentication domain | mydomain.com |
Default Search Method
Description: Get/Set default search method for finding elements
In: search method
Out: true
Example(s): | Set Default Search Method | id |
Allowed values: see element locators
New Browser
Description: Creates a new browser instance and makes it current. Returns an ID. For browser names see Reference: Browsers
In: browser name
Out: the ID of the browser session
Example(s): | $Id= | new browser | Chrome Headless |
New Options For
Description: Create a new options object for a browser type
In: The browser to create the options object for
Out: The options object
Example(s): | $object= | New Options For | Chrome |
New Remote Browser At Address [With Capabilities | With Options]
Description: Specifies that the test will be run at a remote Selenium server. Returns the driver ID. For browser names see Reference: Locators
In: browser name, remote Selenium URL [, capabilities list or options object]
Out: the ID of the browser session
Example(s): | $Id= | new browser | Chrome Headless | at address | http://machine:6667 |
| $Id= | new browser | Edge | at address | http://machine:6667 | with options | $options |
Open
Description: Opens the specified URL in the browser and wait for it to load
In: URL of page to be opened
Out: succeeded? (true/false)
Example(s): | open | https://www.google.com |
Remote Browser Path
Description: set the remote driver path (default /wd/hub)
In: Path to use (if set)
Out: Path in use (if get)
Example |Remote Browser Path|/|
Reset Timeout
Description: Resets the timeout to the default value (3 seconds)
In: -
Out: -
Example(s): | reset timeout |
Search Delimiter
Description: Get or set the delimiter for method and locator in element searches (default is โ€˜:โ€™)
In: delimiter character (set)
Out: delimiter character (get)
Example(s): | Search Delimiter | : |
Select Window
Description: Selects a window using a window handle (which was returned using Wait For New Window Name or Current Window Name). If no handle is specified, it will select the window that was used for the Open command.
In: [window handle]
Out: whether or not the selection was successful (true/false)
Example(s): | select window | $handle |
Set Browser [With Options]
Description: Sets the browser to be used for the web tests
In: local browser name [, options object]
Out: whether or not the operation succeeded (true/false)
Example(s): | ensure | set browser | chrome | with options | $options |
| ensure | set browser | internet explorer |
Note(s): This command will raise a StopTestException in case it was unable to identify the right browser, which will cause FitNesse to stop processing the rest of the test
Set Driver
Description: Set the current browser driver using its ID (returned earlier by New Browser)
In: session ID
Out: whether or not the operation succeeded (true/false)
Example(s): | set driver | $id |
Set Proxy Type
Description: Sets the http and SSL proxy for the test
In: proxy type (AutoDetect, Direct, System)
Out: whether or not the operation succeeded (true/false)
Example(s): | set proxy type | Direct |
Note(s): This is a system wide setting, so coordinate carefully and revert to original values after the test.
Set Proxy Type Value
Description: Sets the http and SSL proxy for the test
In: proxy type (ProxyAutoConfigure, Manual) and value to set.
Out: whether or not the operation succeeded (true/false)
Example(s): | set proxy type | Manual | value | http://proxy:8080 |
Note(s): This is a system wide setting, so coordinate carefully and revert to original values after the test.
Set Remote Browser At Address [With Capabilities | with Options]
Description: Specifies that the test will be run at a remote Selenium server.
In: remote browser name, URL of remote Selenium server, [key-value list of capabilities or options object])
Out: success? (true/false)
Example(s): | set remote browser | chrome | at address | http://machine:4567 |
Note(s):
Set Timeout Seconds
Description: Set the default timeout for all wait commands. Default value is 3 seconds
In: timeout in seconds
Out: -
Example(s): | set timeout | 7 | seconds |
Store Window Handles
Description: Stores all the window handles that the browser driver handles, including the main window.
In: -
Out: success? (true/false)
Example(s): | Store Window Handles |
Window Size (Property)
Description: Set or get the size of a browser window (width, height)
In: location (width x height in pixels)
Out: success? (true/false)
Example(s): | set window size | 1024 x 768 |
| show | window size |

Session Inquiry

Config
Description: Return a configuration value
In: the key
Out: the associated value
Example(s): | show | config | InternetExplorer.IgnoreProtectedModeSettings |
Current Window Name
Description: Return the internal name (handle) of the current browser window. This can be used later in a Select Window command.
In: -
Out: window handle
Example(s): | $mainWindow= | current window name |
Driver ID
Description: Return the ID of the current driver
In: -
Out: the ID
Example(s): | $driver= | Driver ID |
Note(s): Can be used when using multiple browser windows, e.g. for cross-window drag/drop.
Page Count
Description: Returns the number of open pages (tabs, newly opened windows) for this browser instance.
In: -
Out: Number of open pages (integer)
Example(s): | ensure | Protected Modes Are Equal |
Protected Modes Are
Description: Check if Protected Mode for all security zones have the same value, and throw a StopTestException if not. If OFF, then all must be off, if ON, all must be on. EQUAL requires all values to be the same (all ON or all OFF).
In: ON, OFF or EQUAL
Out: True if protected mode for all zones meets the criterion
Example(s): | ensure | Protected Modes Are | Equal |
Note(s): Internet Explorer requires these values to be all the same for Webdriver to operate properly
Version Info
Description: Displays version info of the fixture
In: SHORT | EXTENDED | DEFAULT
Out: short, extended or default version info (any other value is interpreted as Default)
Example(s): | show | version info | extended |
Wait For New Window Name
Description: After clicking a link that is known to open a new window, wait for that new window to appear
In: -
Out: new window handle (to be used for selecting the window)
Example(s): | $window= | Wait For New Window Name |
Wait Seconds
Description: Wait the specified number of seconds (can use fractions)
In: number of seconds
Out: -
Example(s): | Wait | 3.5 | seconds |
โš ๏ธ **GitHub.com Fallback** โš ๏ธ