Determining the Number of Pages

Applies to TestComplete 14.20, last modified on September 11, 2019

Page controls in iOS applications display a number of dots that correspond to pages available in the application. When working with page controls, you may need to determine the number of pages the control displays.

This topic describes how to get the number of pages from tests.

Using the wPageCount Property

To determine the number of pages in the page control, you can use the wPageCount property of the iOS PageControl test object that TestComplete automatically associates with the page control.

The following sample code obtains the number of pages in the page control and posts it to the test log:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the PageControl object
  var p = Mobile.Device().Process("SampleApp");
  var pageControl = p.Window().PageControl();

  // Get the number of pages and post it to the test log
  var count = pageControl.wPageCount;
  Log.Message("The number of pages is " + aqConvert.VarToStr(count));
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the PageControl object
  p = Mobile.Device().Process("SampleApp")
  pageControl = p.Window().PageControl()

  # Get the number of pages and post it to the test log
  count = pageControl.wPageCount
  Log.Message("The number of pages is " + str(count))

VBScript

Sub Test
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the PageControl object
  Set p = Mobile.Device.Process("SampleApp")
  Set pageControl = p.Window().PageControl

  ' Get the number of pages and post it to the test log
  count = pageControl.wPageCount
  Log.Message("The number of pages is " + aqConvert.VarToStr(count))
End Sub

DelphiScript

procedure Test();
var p, pageControl, count;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the PageControl object
  p := Mobile.Device.Process('SampleApp');
  pageControl := p.Window().PageControl();

  // Get the number of pages and post it to the test log
  count := pageControl.wPageCount;
  Log.Message('The number of pages is ' + aqConvert.VarToStr(count));
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the PageControl object
  var p = Mobile["Device"]["Process"]("SampleApp");
  var pageControl = p["Window"]()["PageControl"]();

  // Get the number of pages and post it to the test log
  var count = pageControl["wPageCount"];
  Log["Message"]("The number of pages is " + aqConvert["VarToStr"](count));
}

Determining the Selected Page From Keyword Tests

To determine the number of pages in the page control from keyword tests, use the On-Screen Action or Call Object Method operation to access the properties described above. See Getting and Setting Object Property Values.

See Also

Working With iOS Page Controls
Navigating Through Application Pages
Determining the Selected Page
wPageCount Property (iOS Controls)

Highlight search results