Skip to content

Instantly share code, notes, and snippets.

@datakurre
Last active June 17, 2022 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datakurre/0bd789d62fb6173e0c5c81eb022c8538 to your computer and use it in GitHub Desktop.
Save datakurre/0bd789d62fb6173e0c5c81eb022c8538 to your computer and use it in GitHub Desktop.
Example robotframework-seleniumtestability test suites for Plone
*** Settings ***
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Library Selenium2Library
Test Setup Run keywords Plone test setup
Test Teardown Run keywords Plone test teardown
*** Variables ***
${SELENIUM2LIBRARY_PLUGINS} ${None}
*** Keywords ***
Test rendering cheatsheet
Go to ${PLONE_URL}/@@test-rendering-cheatsheet
Element should be visible css=.tooltip-demo button[data-bs-placement="top"]
... Known test rendering cheatsheet element was not visible
Testability is not available
Log ${SELENIUM2LIBRARY_PLUGINS}
${result}= Execute javascript return typeof testability === "object"
Should not be true ${result} Known testability resource was unexpectedly found
Relatively small window
Set window size 1024 480
Scroll to bottom
Execute javascript window.scroll(0, document.body.scrollHeight)
# Minimal sleep seems to be still required for testability to catch up
Sleep 0.1 s
Cannot mouse over a known element
${status}= Run keyword and return status
... Mouse over css=.tooltip-demo button[data-bs-placement="top"]
Should not be true ${status}
*** Test Cases ***
Scenario: Testability has been disabled for this suite
Given test rendering cheatsheet
Then testability is not available
Scenario: Testability is required to scroll to the bottom of a long page without long wait
Given relatively small window
And test rendering cheatsheet
When scroll to bottom
Then cannot mouse over a known element
*** Settings ***
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Library Selenium2Library
Test Setup Run keywords Plone test setup
Test Teardown Run keywords Plone test teardown
*** Variables ***
${SELENIUM2LIBRARY_PLUGINS} SeleniumTestability;True;30 Seconds;True
*** Keywords ***
Test rendering cheatsheet
Go to ${PLONE_URL}/@@test-rendering-cheatsheet
Element should be visible css=.tooltip-demo button[data-bs-placement="top"]
... Known test rendering cheatsheet element was not visible
Testability is available
Log ${SELENIUM2LIBRARY_PLUGINS}
${result}= Execute javascript return typeof testability === "object"
Should be true ${result} Known testability resource was not found
Relatively small window
Set window size 1024 480
Scroll to bottom
Execute javascript window.scroll(0, document.body.scrollHeight)
# Minimal sleep seems to be still required for testability to catch up
Sleep 0.1 s
Mouse over a known element
Mouse over css=.tooltip-demo button[data-bs-placement="top"]
*** Test Cases ***
Scenario: Testability has been enabled for this suite
Given test rendering cheatsheet
Then testability is available
Scenario: Testability allows scrolling to the bottom of a long page with minimal wait
Given relatively small window
And test rendering cheatsheet
When scroll to bottom
Then mouse over a known element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment