Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorial:scripting_state_model [2020/07/17 20:50] admin [User Variables] |
tutorial:scripting_state_model [2021/01/05 03:00] (current) |
||
---|---|---|---|
Line 37: | Line 37: | ||
- | Besides triggers, scripts are also used for building UI Page Objects, Cucumber style test step definition and MCases, which are out of scope of this tutorial. | + | Besides triggers, scripts are also used for building UI Page Objects, |
===== Model triggers ===== | ===== Model triggers ===== | ||
Line 112: | Line 112: | ||
| | ||
- | ===== User and environment | + | ==== Web App Automation==== |
+ | For test automation, for example web application you would activate // | ||
+ | |||
+ | For example: | ||
+ | |||
+ | | ||
+ | |||
+ | === Page Object=== | ||
+ | You could also use //PAGES// tab to define page object: | ||
+ | // | ||
+ | | ||
+ | | ||
+ | elem = mainPage.addElement(' | ||
+ | | ||
+ | $SELENIUM.getWebDriver().findElement(elem.locator).click(); | ||
+ | }) | ||
+ | |||
+ | Then in // | ||
+ | | ||
+ | |||
+ | The advantage of using page objects is that all element locators are organized | ||
+ | |||
+ | === Find Element Locator === | ||
+ | Web element locator can be xpath, css or by id, etc. as supported by // | ||
+ | |||
+ | There are many browser add-on/ | ||
+ | |||
+ | ===== User variables ===== | ||
The variables that you created/ | The variables that you created/ | ||
Line 136: | Line 163: | ||
===== Assert and track requirements ===== | ===== Assert and track requirements ===== | ||
+ | It's the responsibility of your scripts (TRIGGERS) to check and validate that AUT is behaving correctly. Your script does this by checking elements on AUT through //plugins// functions and assert that AUT elements have the expected values. | ||
+ | |||
+ | For simplicity sake, we will just use a random number generator to simulate the values from your AUT and use that to demonstrate how to perform the assertion and tracking the requirements. | ||
+ | |||
+ | The assert and tracking requirement are done with one of the two $SYS functions: | ||
+ | |||
+ | * $SYS.assertTrue (' | ||
+ | * $SYS.assertFalse (' | ||
+ | |||
+ | where ' | ||
+ | |||
+ | As example, the following script will assert random number is greater than 5: | ||
+ | |||
+ | | ||
+ | |||
+ | You may also perform check with if/else and then raise the defect explicitly, for example: | ||
+ | | ||
+ | if ($RANDOM.randNum(0, | ||
+ | $SYS.addReqPassed (' | ||
+ | } | ||
+ | else { | ||
+ | $SYS.addReqFailed (' | ||
+ | } | ||
+ | |||
+ | The requirement ' | ||
+ | |||
+ | Add your own script to perform assertion and requirement tracking to the model TRIGGERS, re-run the model, and check [[../ | ||
+ | |||
+ | |||
===== Initialization scripts ===== | ===== Initialization scripts ===== | ||
+ | Often times you may want to pass some configuration settings to your model scripts, for example, the AUT url which might change depending on if you are running your model against your development environment or QA environment or for this tutorial, maybe we want to change the threshold value of the random number the system must generate - which we have hard-coded to 5. | ||
+ | |||
+ | You could certainly accomplish this by setting // | ||
+ | |||
+ | // | ||
+ | |||
+ | |||
+ | |||