Skip to content

Commit

Permalink
shows how to use check step assertions for CI/CD integration
Browse files Browse the repository at this point in the history
  • Loading branch information
kensoh authored Apr 6, 2019
1 parent 632673c commit da279b1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/samples/7_testing
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ https://ca.finance.yahoo.com
// https://github.com/kelaberetiv/TagUI#cheat-sheet

// use check step for testing of conditions (text in quotation marks, either " or ' works)
read search-buttons to search_button_text
check search_button_text equals to "Search" | "search button text is correct" | "search button text is wrong"
read uh-tb-home to header_home_text
check header_home_text equals to "Home" | "header text is correct" | "header text is wrong"

// when TagUI is run with test option, check step automatically performs test assertions
// test assertions are used to track if conditions to be met in a test scenario are all met
// the test assertions will give CasperJS the details needed to output a XUnit XML file,
// which is compatible with continuous integration tools such as Jenkins (for CI/CD)

// check whether the search button exists
check present('search-buttons') | 'search button exists' | 'search button does not exist'
check present('//*[@id="search-button"]') | 'search button exists' | 'search button does not exist'

// check whether the search box is visible
// check whether the search box is visible, using its @aria-label attribute - Search
// something can exists on webpage but set as hidden or not showing in its property
check visible('uh-search') | 'search box is visible' | 'search box is not visible'
check visible('Search') | 'search box is visible' | 'search box is not visible'

// check whether the search button text is correct
// same as earlier example above but with output of button text
read search-buttons to button
check button equals to 'Search' | 'search button text is correct - ' button | 'search button text is wrong - ' button
// check whether the header home text is correct
// similar to earlier example above but with output of header home text
read uh-tb-home to header_home_text
check header_home_text equals to 'Home' | 'text is correct - ' header_home_text | 'text is wrong - ' header_home_text

// check that the page url has yahoo in it (\' can be used to escape the single quote)
check url() contains 'yahoo' | 'url contains \'yahoo\'' | 'url does not contain \'yahoo\''
Expand All @@ -39,7 +39,7 @@ check text() contains "My Portfolio" | "page text contains My Portfolio" | "page

// check that number of header menu items are more than or equals to 6
// spaces between check step separator | is optional and up to you
check count('uh-tb-') more than or equals to 6|'header menu items >= 6'|'header menu items < 6'
check count('uh-tb-') more than or equals to 6 | 'header menu items >= 6' | 'header menu items < 6'

// you can also assign to a variable for use or further processing
count_number = count('uh-tb-')
Expand All @@ -53,7 +53,7 @@ echo 'count_number = ' count_number
start = timer()

// make some navigational steps, by searching for microsoft
type uh-search as microsoft
type Search as microsoft
click //*[@id="search-button"]

// use timer() as a stopwatch to track elapsed time between calls
Expand Down

0 comments on commit da279b1

Please sign in to comment.