Commands
The Selenium API defines dozens of commands that can be categorized into the following:
• Actions
• Accessors
• Assertions
Actions
Actions are commands that change the state of the application like clicking links or buttons, select an option in a <select> or type a character sequence in a given textbox.
Eg : clickAndWait(locator) command which will trigger a click and stop the test until the browser has finished loading a new page.
Accessors
Accessors inspect the state of the application and store values in variables.
Eg : storeCookies(variableName) stores all the cookies in use in the current page in the variable variableName.
Assertions
Assertions are also able to inspect the current page but:
- They’re made to return a boolean value
- This boolean represents the conformity of the element to a desired pattern
- Usually, the pattern represents the state of an element.
• Assertions come into 3 flavors:
- assert : if assertion fails, test is aborted and marked as failed : assertTitle(pattern) will fail if the title of the page doesn’t correspond to the pattern argument.
- verify : if a verification fails, the test doesn’t stop but a trace will be printed in the log.
- waitFor : these commands pause the test until a condition is satisfied or a timeout is reached.
No comments:
Post a Comment