Support methods for user interface tests
pcSmokeTestClassBase.Method: dismissAndGetAlert
dismissAndGetAlert() : String
The dismissAndGetAlert method closes an alert dialog. The method returns the alert message.
class MyTestClass extends pcSmokeTestClassBase {
function testMySampleTest() {
...
// Click the Page.Screen.Edit button
myScreenPage.MyScreen.MyEditButton.click()
dismissAndGetAlert()
...
}
}
Method: dismissAndGetConfirmation
dismissAndGetConfirmation() : String
The dismissAndGetConfirmation method closes a confirmation dialog. The method returns the confirmation message.
class MyTestClass extends pcSmokeTestClassBase {
function testMySampleTest() {
...
// Click the Page.Screen.Close button. Not expecting a confirmation dialog.
myScreenPage.MyScreen.MyCloseButton.click()
if(isConfirmationShowing()) {
PLAssertions.fail("Unable to close screen because:\n" + dismissAndGetConfirmation())
}
...
}
}
Method: getCurrentPage
getCurrentPage() : Object
The getCurrentPage method retrieves the Gosu object that represents the current PCF page.
For every PCF file, the framework provides a corresponding class that includes a strongly typed property for each of the page's elements. Retrieving the page object of a PCF file enables test code to access the object's properties to evaluate and modify the page's fields, buttons, and other items, including sub-objects, like detail views.
// Retrieve the page object for the current PCF page
var page = getCurrentPage()
// Retrieve the detail view sub-object on this page
var detailView = page.MyDetailScreen.MyDetailView
// The detail view has an input with an ID value of "Code." Set its value.
detailView.Code.Value = 'X'
// The page has an Update button. Click it.
page.Update.click()
// Verify the detail view's input value still contains the modified value.
if (detailView.Code.Value != 'X') {
// ... Handle the issue
}
Method: getCurrentWorksheet
getCurrentWorksheet() : Object
The getCurrentWorksheet method retrieves the Gosu object that represents the current
worksheet. If there is no current worksheet, the method returns null.
A PCF worksheet is similar to a PCF page. The framework provides a corresponding class for each worksheet. The class includes a strongly-typed property for each of the worksheet's elements. Retrieving the worksheet object enables test code to access the object's properties to evaluate and modify the worksheet's fields.
// Click the page's Show button to show a worksheet.
page.Show.click()
assertThat(getCurrentWorksheet()).isNotNull()
// Retrieve the worksheet and verify its expected contents exist
var myWorksheet = getCurrentWorksheet() as pcftest.MyAwesomeWorksheet
assertThat(myWorksheet.itemsLV._Entries.Count).isEqualTo(10)
assertThat(myWorksheet.itemsLV._Entries[0].Name.Text).isEqualTo("Awesome")
// Click worksheet item's Delete button and verify the expected behavior
myWorksheet.itemsLV._Entries[0].Delete.click()
assertThat(getCurrentWorksheet().itemsLV._Entries.Count).isEqualTo(9)
Method: goToEntryPoint
goToEntryPoint(entryPoint : String) : Object
goToEntryPoint(entryPoint : String, parameters : Map<String, String>) : Object
The goToEntryPoint method transfers the user interface focus to a specified page. Multiple method signatures are provided.
The entryPoint argument references the name of the page to transfer to. The parameters argument is a list of key-value pairs that are passed as arguments to the loaded page.
The method returns the page object of the page transferred to.
class MyTestClass extends PCSmokeTestClassBase {
// Any point in the application can be accessed from the tab bar
var _tabBar : pcftest.TabBar as TabBar
// ... Constructors and other overridden methods
/**
* Log in a user with the given name and password. Initialize the TabBar property.
*/
function login(username : String, password : String) {
var startPage = (this.goToEntryPoint("Login") as pcftest.Login).login(username, password)
_tabBar = (startPage as pcftest.DesktopActivities)._parent.TabBar
}
}
Method: isConfirmationShowing
isConfirmationShowing() : boolean
The isConfirmationShowing method determines whether a confirmation dialog is showing.
The method returns true if a confirmation dialog is showing. Otherwise, returns
false.
For example code, see the dismissAndGetConfirmation method.
Method: refreshPage
refreshPage() : Object
The refreshPage method posts the current page to the server. The operation is equivalent to refreshing the browser window.
The method returns the page object for the refreshed page.
