Skip to content

Selenium

Browse implementations

About by input

Selenium actions selecting an elements require a selector and specifying the selection type.
See Selenium by documentation for further details.
Chutney provides the following values :

  • "id"
  • "name"
  • "className"
  • "cssSelector"
  • "xpath"
  • "zk"
About ZK

ZK is an open source Java framework for building web and mobile apps.
When using ZK, element IDs are gerenated and managed by the framework. Thus, impossible to know beforehand.
But you can get HTML IDs by calling ZK at runtime with JS using the widget's ID.
So, Chutney provides it for you.

About web-driver input

Most actions requires a web-driver input. It's value comes from the output off the action DriverInit.
So the most probable value for it would come from the execution context : ${#webDriver}

While required in a Chutney scenario, it is set by default using the Chutney Kotlin DSL so you don't need to provide it.

Click🔗

Performs a click on an element. Element is expected to be clickable.
See WebElement.click() and ExpectedConditions.elementToBeClickable() for further details.

It takes a screenshot in case of error.

Required Name Type Default Note
* web-driver String
* selector String
* by String
wait Integer 1 seconds

Example🔗

1
2
3
4
SeleniumClickAction(
    selector = "//button[text()=\"Some text\"",
    by = SELENIUM_BY.xpath
)

Close🔗

This action close the current window, quitting the browser if it's the last window currently open.
See WebDriver.close() for further details.

Required Name Type Default
* web-driver String

Example🔗

SeleniumCloseAction()

DriverInit🔗

This action instantiate a webdriver

Important

Firefox is the default browser and browser input should be empty, but you should provide browserPath input.
For using IE, put "Internet Explorer" as browser input, browserPath is not required when using IE.

IE running options

IE runs with the following options :

  • "AcceptInsecureCertificates": true
  • "disable-popup-blocking": true
  • "enablePersistentHover": true
  • "ensureCleanSession": true
  • "ignoreProtectedModeSettings": true
  • "ignoreZoomSetting": false
  • "introduceInstabilityByIgnoringProtectedModeSettings": true
  • "javascriptEnabled": true
  • "nativeEvents": true
  • "unexpectedAlertBehaviour": "accept"
FF running options

FF runs with the following options :

  • Headless: true
  • Log level: FATAL
Required Name Type Default Accepted Value
* driverPath String
* browserPath String
browser String Firefox Internet Explorer
Name Type
webDriver WebDriver

Finally Action🔗

Performs the action Quit when the scenario ends.

Example🔗

1
2
3
4
SeleniumDriverInitAction(
    browserPath = "/path/to/the/browser/",
    driverPath = "/path/to/the/webdriver/"
)

Get🔗

This action load a new web page in the current browser window.
See WebDriver.get(String url) for further details.

Required Name Type Note
* web-driver String
selector String (Weird implemention) Used as a boolean. If null, the page is opened in current window. If not the page is opened in a new window
* value String The URL to load. Must be a fully qualified URL
Name Type Note
outputGet String This value can be used to switch to this window using action SwitchTo.
See WebDriver.getWindowHandle() for further details.

Example🔗

1
2
3
SeleniumGetAction(
    url = "http://www.chutney-testing.com/" 
)

GetAttribute🔗

Get the value of the given attribute of the element.
See WebElement.getAttribute() for further details.

Required Name Type Default Note
* web-driver String
* selector String
* by String
wait Integer 1 seconds
attribute String "value"
Name Type
outputAttributeValue String

Example🔗

1
2
3
4
5
SeleniumGetAttributeAction(
    selector = "usernameInput",
    by = SELENIUM_BY.NAME,
    attribute = "type"
)

GetText🔗

This action returns the visible (i.e. not hidden by CSS) text of an element, including sub-elements.
See WebElement.getText() for further details.

Required Name Type Default Note
* web-driver String
* selector String
* by String
wait Integer 1 seconds
Name Type Note
outputGetText String Returns the value of attribute "value" when text is empty

Example🔗

1
2
3
4
SeleniumGetTextAction(
    selector = "usernameInput",
    by = SELENIUM_BY.NAME,
)

Hover and click🔗

Moves the mouse to the middle of the element then performs a click.
See Actions.moveToElement() and Click for further details.

Required Name Type Default Note
* web-driver String
* selector String
* by String
wait Integer 1 seconds

Example🔗

1
2
3
4
SeleniumHoverThenClickAction(
    selector = "myHyperLink",
    by = SELENIUM_BY.id
)

Quit🔗

Important

This action is not available with the Kotlin DSL since it is performed by default when the scenario ends.

This action quits the driver, closing every associated window.
See WebDriver.quit() for further details.

Required Name Type Default
* web-driver String

Remote Driver Init🔗

Note

browser input values :

  • "chrome"
  • "internet explorer"
  • "firefox"
Internet Explorer running options

IE runs with the following options :

  • "AcceptInsecureCertificates": true
  • "disable-popup-blocking": true
  • "enablePersistentHover": true
  • "ensureCleanSession": true
  • "ignoreProtectedModeSettings": true
  • "ignoreZoomSetting": false
  • "introduceInstabilityByIgnoringProtectedModeSettings": true
  • "javascriptEnabled": true
  • "nativeEvents": true
  • "unexpectedAlertBehaviour": "accept"
Firefox running options

Firefox runs with the following options :

  • Headless: false
  • Log level: FATAL
Chrome running options

Chrome runs with the following options :

  • start-maximized: true
Required Name Type Default Note
* hub String The URL of the remote Selenium Hub
browser String firefox
Name Type
webDriver WebDriver

Finally Action🔗

Performs the action Quit when the scenario ends.

Example🔗

1
2
3
4
SeleniumRemoteDriverInitAction(
    hub = "http://my.hub.url:4242/",
    browser = "chrome"
)

Screenshot🔗

Takes a screenshot, available in the execution report as a Base64 String.
See TakesScreenshot.getScreenshotAs() and OutputType.BASE64 for further details.

Required Name Type
* web-driver String

Example🔗

SeleniumScreenShotAction()

Scroll to🔗

Scroll the page to make the element visible and align to the top.
See Element.scrollIntoView() for further details.

Required Name Type Default Note
* web-driver String
* selector String
* by String
wait Integer 1 seconds

Example🔗

1
2
3
4
SeleniumScrollToAction(
    selector = "/html/body/form[1]",
    by = SELENIUM_BY.xpath
)

Send keys🔗

This action simulate typing into an element, which may set its value.
See WebElement.sendKeys()

Required Name Type Default Note
* web-driver String
* selector String
* by String
* value String The value to type
wait Integer 1 seconds

Example🔗

1
2
3
4
5
SeleniumSendKeysAction(
    selector = "usernameInput",
    by = SELENIUM_BY.NAME,
    value = "the hitchhiker"
)

Set browser size🔗

This action set the size of the current window.
See WebDriver.Window.setSize() for further details.

Required Name Type Default
* width Integer
* height Integer

Example🔗

1
2
3
4
SeleniumSetBrowserSizeAction(
    width = 640,
    height = 480
)

Switch to🔗

Note

By default it selects either the first frame on the page, or the main document when a page contains iframes.
See WebDriver.TargetLocator for further details.

switchType accepted values :

  • "Frame"
  • "Popup"
  • "Window"
  • "AlertOk" (Switch to alert and click on the OK button)
  • "AlertCancel" (Switch to alert and click on the Cancel button)
Required Name Type Default Note
* web-driver String
* selector String
* by String
wait Integer 1 seconds
switchType String
Name Type
outputSwitchTo This value can be used to switch to this element later.

Example🔗

1
2
3
4
5
SeleniumSwitchToAction(
    selector = "outputGet".spEL(),
    by = SELENIUM_BY.id,
    switchType = SELENIUM_SWITCH.Window
)

Wait🔗

This action waits N seconds or until the expected conditions are met.

About value input

Expected conditions can be combined.
Available values are :

  • "elementToBeSelected"
  • "elementToBeClickable"
  • "frameToBeAvailableAndSwitchToIt"
  • "invisibilityOfElementLocated"
  • "visibilityOfElementLocated"
  • "visibilityOfAllElementLocated"
  • "presenceOfElementLocated"
  • "presenceOfAllElementLocated"
  • "and"
  • "or"
  • "not"
Required Name Type Default Note
* web-driver String
* selector String
* by String
wait Integer 1 seconds
value String

Example🔗

1
2
3
4
5
SeleniumWaitAction(
    selector = "//button[text()=\"Some text\"",
    by = SELENIUM_BY.xpath,
    value = "elementToBeClickable"
)