GXtest UI Commands - Assertions

Unofficial Content

Assertions in UI testing is (like in Unit Testing as well) the only way to determine if a test is successful. 

Typically, Assertions compares expected values (that you have defined on your test data) against obtained ones using different UI commands (ie. GetText, GetValueGetTitle, etc).  

Anyway you can use assertions by comparing anything you want to compare to check and determine if a test is successful, even database values using foreach statements. 

The following example shows a UI test combining with different commands and assertions: 

//Start webdriver

//Get Source and Refresh msg
&msg_refreshed_on1 = &driver.GetTextByCSS("span.gx-warning-message")
&wp_source = &driver.GetSource()
//Check the Source is there
AssertBoolEquals(true,&wp_source.Contains("<title>photos_wp</title>"),"not matching PAGE SOURCE.")

//Check the title, change it using JS and then check it again:
AssertStringEquals("photos_wp", &driver.GetTitle(), "not matching title")
&driver.ScriptEval("document.title = 'New Title';")
AssertStringEquals("New Title", &driver.GetTitle(), "not matching title")

//Wait 1 sec to let the function Time() to change.
&dum = sleep(1)

//Get the message again, and check if it is reloaded with new Time()
&msg_refreshed_on2 = &driver.GetTextByCSS("span.gx-warning-message")
AssertBoolEquals(false,&msg_refreshed_on1=&msg_refreshed_on2, "it seems that didn't refresh")
&wp_source = &driver.getSource()
AssertBoolEquals(true,&wp_source.Contains(&msg_refreshed_on2),"not matching PAGE SOURCE.")
AssertBoolEquals(false,&wp_source.Contains(&msg_refreshed_on1),"matching PAGE SOURCE.")

//Close the browser