The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach. |
TestComplete recognizes individual elements of web pages displayed in hybrid mobile applications and provides a number of search methods you can use. These methods are the same as those used to find web page elements in standard web browsers.
Keep in mind that the object hierarchy of hybrid mobile applications differs from that of web browsers. Namely, the Page
object is obtained in a different way:
-
When testing a web page in a browser, the path to the
Page
object looks like this:JavaScript, JScript
// Using a mapped name
page = Aliases.browser.pageExampleDomain;
// Without name mapping
page = Sys.Browser().Page("http://www.example.com");Python
# Using a mapped name
page = Aliases.browser.pageExampleDomain;
# Without name mapping
page = Sys.Browser().Page("http://www.example.com");VBScript
' Using a mapped name
Set page = Aliases.browser.pageExampleDomain
' Without name mapping
Set page = Sys.Browser().Page("http://www.example.com")DelphiScript
// Using a mapped name
page := Aliases.browser.pageExampleDomain;
// Without name mapping
page := Sys.Browser().Page('http://www.example.com');C++Script, C#Script
// Using a mapped name
page = Aliases["browser"]["pageExampleDomain"];
// Without name mapping
page = Sys["Browser"]()["Page"]("http://www.example.com"); -
Whereas in hybrid mobile applications, the path looks like this:
-
For Android applications:
JavaScript, JScript
// Using a mapped name
page = Aliases.Device.Process_hybridapp.RootLayout.Layout_webView1.pageExampleDomain;
// Without name mapping
page = Mobile.Device("Nexus 7").Process("com.example.hybridapp").RootLayout("").WebView("webView1").Page("http://example.com/");Python
# Using a mapped name
page = Aliases.Device.Process_hybridapp.RootLayout.Layout_webView1.pageExampleDomain;
# Without name mapping
page = Mobile.Device("Nexus 7").Process("com.example.hybridapp").RootLayout("").WebView("webView1").Page("http://example.com/");VBScript
' Using a mapped name
Set page = Aliases.Device.Process_hybridapp.RootLayout.Layout_webView1.pageExampleDomain
' Without name mapping
Set page = Mobile.Device("Nexus 7").Process("com.example.hybridapp").RootLayout("").WebView("webView1").Page("http://example.com/")DelphiScript
// Using a mapped name
page := Aliases.Device.Process_hybridapp.RootLayout.Layout_webView1.pageExampleDomain;
// Without name mapping
page := Mobile.Device('Nexus 7').Process('com.example.hybridapp').RootLayout('').WebView('webView1').Page('http://example.com/');C++Script, C#Script
// Using a mapped name
page = Aliases["Device"]["Process_hybridapp"]["RootLayout"]["Layout_webView1"]["pageExampleDomain"];
// Without name mapping
page = Mobile["Device"]("Nexus 7")["Process"]("com.example.hybridapp")["RootLayout"]("")["WebView"]("webView1")["Page"]("http://example.com/"); -
For iOS applications:
JavaScript, JScript
// Using a mapped name
page = Aliases.Device.Process_hybridapp.Window0.WebView0.pageExampleDomain;
// Without name mapping
page = Mobile.Device("John Smith iPad").Process("SampleHybridApp").Window(0).WebView(0).Page("http://example.com/");Python
# Using a mapped name
page = Aliases.Device.Process_hybridapp.Window0.WebView0.pageExampleDomain;
# Without name mapping
page = Mobile.Device("John Smith iPad").Process("SampleHybridApp").Window(0).WebView(0).Page("http://example.com/");VBScript
' Using a mapped name
Set page = Aliases.Device.Process_hybridapp.Window0.WebView0.pageExampleDomain
' Without name mapping
Set page = Mobile.Device("John Smith iPad").Process("SampleHybridApp").Window(0).WebView(0).Page("http://example.com/")DelphiScript
// Using a mapped name
page := Aliases.Device.Process_hybridapp.Window0.WebView0.pageExampleDomain;
// Without name mapping
page := Mobile.Device('John Smith iPad').Process('SampleHybridApp').Window(0).WebView(0).Page('http://example.com/');C++Script, C#Script
// Using a mapped name
page = Aliases["Device"]["Process_hybridapp"]["window"]["0"]["pageExampleDomain"];
// Without name mapping
page = Mobile["Device"]("John Smith iPad")["Process"]("SampleHybridApp")["window"](0)["WebView"](0)["Page"]("http://example.com/");
-
The object hierarchy below the Page
object (that is, the elements of the displayed web page) is identical for the web and hybrid mobile applications. See Addressing Objects in Hybrid Mobile Applications (Legacy).
Taking into account these differences, you can search for web page elements using the same methods and techniques that you use for web browsers:
To learn about... | See these topics... |
---|---|
Overview and comparison of available search approaches |
Find Web Objects |
Searching with common Find methods | Finding Web Objects Using Common Find Methods |
Using XPath for the search | Finding Web Objects Using XPath Expressions |
Using CSS3 selectors for the search | Finding Web Objects Using CSS Selectors |
Notes on Working With FRAMEs
-
For Android 4.1 or later: if a page is loaded from a local drive (not from the Web), then to access elements in its frames, you need to enable the Update WebView settings to allow access to frame elements setting. To view or change the setting, open the Open Applications | Hybrid mobile category of the project properties.
-
TestComplete does not support using XPath expressions for searching web objects in nested frames.
See Also
Common Tasks for Hybrid Mobile Application Testing (Legacy)
Testing Hybrid Mobile Applications - Overview (Legacy)