Forum Discussion
TanyaYatskovska
11 years agoSmartBear Alumni (Retired)
Hi Keerthana,
As you are testing web pages - TestComplete can recognize all objects on the page. So, you can use your own ClickItem function. For example, the code below demonstrates how to click the Mimbai item on the sample you provided:
function test()
{
var page = NameMapping.Sys.Browser().Page("http://www.ok-soft-gmbh.com/jqGrid/UsageFormetterSelect2.htm");
MyClickItem(page, "Mumbai");
}
function MyClickItem(page, itemText)
{
var panel = page.Panel("gbox_list");
// Click the combo box to open the dropdown
panel.Panel("gview_list").Panel(1).Panel(0).Table(0).Cell(1, 2).Panel(0).Table(0).Cell(0, 1).Panel("s2id_gs_CITY").Link(0).Click();
// Update the object tree. You can find the nearest parent of the dropdown to refresh it. In your example, it's "page"
page.Refresh();
// Wait while the dropdown is fully recognized
if (page.WaitPanel("select2_drop", 3000))
{
// Find the needed item by unique properties. "Mumbai" in this case.
var PropArray = new Array("ClassName", "contentText");
var ValuesArray = new Array("select2-result-label", itemText);
var item = page.Panel("select2_drop").FindChild(PropArray, ValuesArray, 5);
// Click the found item
item.Click()
}
}
As you are testing web pages - TestComplete can recognize all objects on the page. So, you can use your own ClickItem function. For example, the code below demonstrates how to click the Mimbai item on the sample you provided:
function test()
{
var page = NameMapping.Sys.Browser().Page("http://www.ok-soft-gmbh.com/jqGrid/UsageFormetterSelect2.htm");
MyClickItem(page, "Mumbai");
}
function MyClickItem(page, itemText)
{
var panel = page.Panel("gbox_list");
// Click the combo box to open the dropdown
panel.Panel("gview_list").Panel(1).Panel(0).Table(0).Cell(1, 2).Panel(0).Table(0).Cell(0, 1).Panel("s2id_gs_CITY").Link(0).Click();
// Update the object tree. You can find the nearest parent of the dropdown to refresh it. In your example, it's "page"
page.Refresh();
// Wait while the dropdown is fully recognized
if (page.WaitPanel("select2_drop", 3000))
{
// Find the needed item by unique properties. "Mumbai" in this case.
var PropArray = new Array("ClassName", "contentText");
var ValuesArray = new Array("select2-result-label", itemText);
var item = page.Panel("select2_drop").FindChild(PropArray, ValuesArray, 5);
// Click the found item
item.Click()
}
}
Related Content
- 2 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago