When testing an application, you may need to check the title and message of the alert view. To do this, use the wMessage
or wTitle
property of the AlertView
test object. These properties return the alert view message or title respectively. They are available both in script code and in keyword tests.
In Script Code
The following code snippet obtains the title of an alert view control and posts it to the log:
JavaScript, JScript
function Test()
{
// Select the mobile device
Mobile.SetCurrent("iPhone");
// Obtain the AlertView object
var p = Mobile.Device().Process("SampleApp");
var alertview = p.Window(2).AlertView("Alert title");
// Post the title of the AlertView to the log
Log.Message(alertview.wTitle);
}
Python
def Test():
# Select the mobile device
Mobile.SetCurrent("iPhone")
# Obtain the AlertView object
p = Mobile.Device().Process("SampleApp")
alertview = p.Window(2).AlertView("Alert title")
# Post the title of the AlertView to the log
Log.Message(alertview.wTitle)
VBScript
Sub Test()
Dim p, AView
' Select the mobile device
Mobile.SetCurrent("iPhone")
' Obtain the AlertView object
Set p = Mobile.Device.Process("SampleApp")
Set AView = p.Window(2).AlertView
' Post the title of the AlertView to the log
Log.Message(AView.wTitle)
End Sub
DelphiScript
procedure Test();
var
p, alertview;
begin
// Select the mobile device
Mobile.SetCurrent('iPhone');
// Obtain the AlertView object
p := Mobile.Device.Process('SampleApp');
alertview := p.Window(2).AlertView;
// Post the title of the AlertView to the log
Log.Message(alertview.wTitle);
end;
C++Script, C#Script
function Test()
{
// Select the mobile device
Mobile["SetCurrent"]("iPhone");
// Obtain the AlertView object
var p = Mobile["Device"].Process("SampleApp");
var alertview = p["Window"](2)["AlertView"];
// Post the title of the AlertView to the log
Log["Message"](alertview["wTitle"]);
}
In Keyword Tests
To obtain the alert view’s title and message from keyword tests, call the methods described above by using the On-Screen Action or Call Object Method operation. See Calling Object Methods.