TouchNavButton Method (Specific to Android Toolbar Controls)

Applies to TestComplete 14.80, last modified on April 21, 2021
This method is available in legacy mobile tests that work with devices connected to the local computer. To learn how to simulate user actions in newer cloud-compatible mobile tests, see the Simulating user actions in tests section.

Description

The TouchNavButton method simulates touching a navigation button of the toolbar control in an Android application.

Declaration

TestObj.TouchNavButton(Button)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Button [in]    Required    Variant    
Result None

Applies To

The method is applied to the following object:

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameter:

Button

Specifies the desired item. You can enter the item’s index (from 0) or its caption. The caption can contain asterisk (*) or question mark (?) wildcards or regular expressions. The asterisk (*) corresponds to a string of any length (including an empty string), the question mark corresponds to any single character (including none). To specify more complicated parts of a caption, use regular expressions.

The caption can be case-sensitive or case-insensitive depending on the value of the Use case-sensitive parameters project setting.

Result Value

None.

Example

JavaScript, JScript

function TouchButton()
{
  // Select an Android device
  Mobile.SetCurrent("MyDevice");
  
  // Obtain an application
  var app = Mobile.Device().Process("com.example.myapp");
  
  // Obtain a toolbar
  var toolbar = app.RootLayout("").Layout("toolbar_container").Toolbar("toolbar");
  
  // Simulating a touch on a navigation button
  toolbar.TouchNavButton("Button1");
}

Python

def TouchButton():
  # Select an Android device
  Mobile.SetCurrent("MyDevice")
  
  # Obtain an application
  app = Mobile.Device().Process("com.example.myapp")
  
  # Obtain a toolbar
  toolbar = app.RootLayout("").Layout("toolbar_container").Toolbar("toolbar")
  
  # Simulating touch on a navigation button
  toolbar.TouchNavButton("Button1")

VBScript

Sub TouchButton
  Dim app, toolbar
  
  ' Select an Android device
  Mobile.SetCurrent("MyDevice")
  
  ' Obtain an application
  Set app = Mobile.Device.Process("com.example.myapp")
  
  ' Obtain a toolbar
  Set toolbar = app.RootLayout("").Layout("toolbar_container").Toolbar("toolbar")
  
  ' Simulating touch on a navigation button
  Call toolbar.TouchNavButton("Button1")
End Sub

DelphiScript

function TouchButton();
var
  app, toolbar: OleVariant;
begin

  // Select an Android device
  Mobile.SetCurrent('MyDevice');
  
  // Obtain an application
  app := Mobile.Device.Process('com.example.myapp');
  
  // Obtain a toolbar
  toolbar := app.RootLayout('').Layout('toolbar_container').Toolbar('toolbar');
  
  // Simulating touch on a navigation button
  toolbar.TouchNavButton('Button1');
end;

C++Script, C#Script

function TouchButton()
{
  // Select an Android device
  Mobile["SetCurrent"]("MyDevice");
  
  // Obtain an application
  var app = Mobile["Device"]["Process"]("com.example.myapp");
  
  // Obtain a toolbar
  var toolbar = app["RootLayout"]("")["Layout"]("toolbar_container")["Toolbar"]("toolbar");
  
  // Simulating touch on a navigation button
  toolbar["TouchNavButton"]("Button1");
}

See Also

Testing Android Applications (Legacy)
Selecting Action Bar Items
Touch Action (Mobile Objects)

Highlight search results