Getting Clock Control's Time

Applies to TestComplete 14.72, last modified on April 22, 2021
Getting wTime Property

To get the time of the clock control, use the wTime property of the Android Clock object that TestComplete associates with that control. This property returns the time as a string formatted according to the regional setting of the machine performing the test. The following example determines the time on the clock and posts it to the log.

JavaScript, JScript

function Test()
{
  // Select the Android device
  Mobile.SetCurrent("MyDevice");

  // Obtain the clock object
  var p = Mobile.Device().Process("com.example.myapp");
  var TextClock = p.RootLayout("").Layout("layoutTop").Layout("layout1").TextClock("textClock1");
  
  // Get the clock time
  var Time = TextClock.wTime;
  
  // Post the time to the log
  Log.Message(Time);
}

Python

def Test():
  # Select the Android device
  Mobile.SetCurrent("MyDevice")

  # Obtain the clock object
  p = Mobile.Device().Process("com.example.myapp")
  TextClock = p.RootLayout("").Layout("layoutTop").Layout("layout1").TextClock("textClock1")
  
  # Get the clock time
  Time = TextClock.wTime
  
  # Post the time to the log
  Log.Message(Time)

VBScript

Sub Test()
  Dim p, TextClock, Time

  ' Select the Android device
  Mobile.SetCurrent("MyDevice")

  ' Obtain the clock object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set TextClock = p.RootLayout("").Layout("layoutTop").Layout("layout1").TextClock("textClock1")

  ' Get the clock time
  Time = TextClock.wTime
  
  ' Post the time to the log
  Log.Message(Time)
End Sub

DelphiScript

procedure Test();
var
  p, TextClock, Time;
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');

  // Obtain the clock object
  p := Mobile.Device.Process('com.example.myapp');
  TextClock := p.RootLayout('').Layout('layoutTop').Layout('layout1').TextClock('textClock1');
  
  // Get the clock time
  Time := TextClock.wTime;
  
  // Post the time to the log
  Log.Message(Time);
end;

C++Script, C#Script

function Test()
{
  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");

  // Obtain the clock object
  var p = Mobile["Device"].Process("com.example.myapp");
  var TextClock = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout1")["TextClock"]("textClock1");
  
  // Get the clock time
  var Time = TextClock["wTime"];
  
  // Post the time to the log
  Log["Message"](Time);
}

Simulating Actions From Keyword Tests

This topic explains how to obtain the time of the clock control in scripts. You can use the described property in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Working With Android Clock Controls
Touching Clock Controls
wTime Property (Android Controls)

Highlight search results