Forum Discussion
Slightly confused now. Are you facing the issue while clicking the list item from the dropdown or while clicking the dropdown itself?
Error - "There was an attempt..." looks to be for Dropdown click action. If so please check whether all okay with your mapping for the dropdown.
Also, in your function you are checking for listObject.Exists, so you would not get 'Object does not exist' error message for the list item. I expect you should just get that Log.Message - drop down not clicked.
The dropdown gets clicked but it can't find the 'listitem' because of the scrollbar.
- SaravanaKumar_N6 years agoContributor
Got you! We should scroll in to that ListItem before clicking it.
'ClickItem' method will normally would handle those cases. But here it would be slightly tricky.
Can you check ListItem object has any methods like 'Focus' ?
If available, you can do..
listObject.Focus();
Delay(500); // delay may be needed, if not remove it
listObject.Click();
One more solution may work.
In your application, if you manually type in the dropdown and it can select the item you need. Then instead of doing all these actions, we can just do...
dropDown.Keys(menuItem)
- SaravanaKumar_N6 years agoContributor
Then we have to create our own scroll method.
This might work for you, give it a try. Pass the objects - dropdown and listItem to be selected to this method. You may also have to name map your vScroll bar accordigly else update the code as per your need.
function scrollIntoView(dropdown, listItem) { while ( (dropdown.Height < (listItem.Top + listItem.Height)) && ((dropdown.vScroll.Pos + 5) < dropdown.vScroll.Max)) { dropdown.vScroll.Pos += 5; Delay(100); } while (listItem.Top < 0 && (dropdown.vScroll.Pos - 5) > 0) { dropdown.vScroll.Pos -= 5; Delay(100); } }
- russelld6 years agoContributor
During debug mode the listobject don't populate with anything...see attach
I'm guessing I'm using the 'propertyName' & 'value'
var listObject = dropDown.FindChild("ListItem",listItem,30,true);
- SaravanaKumar_N6 years agoContributor
Okay, can you check whether the list item have spaces at begin or ending? or list item string you pass spelled correctly?
May be you can rewrite the method something like this...
function selectDropdownItem(ddlItem, mnuItem) { // jScript var isItemClicked = false; ddlItem.Click(); // click the dropdown aqUtils.Delay(500); var listItems = ddlItem.FindAllChildren("ObjectType", "ListItem", 1, true).toArray(); if (listItems.length > 0) { for (var i = 0; i < listItems.length; i++) { if (aqString.Trim(listItems[i].Caption).toLowerCase() == mnuItem.toLowerCase()) { listItems[i].Click(); isItemClicked = true; break; } } } if (!isItemClicked) { // throw exception like menuitem not available } }
- russelld6 years agoContributor
The lastest function I've added finds all the properties for each listitem but it still won't click the actual item.
The screen shots are the errors and the items found using the debug mode.
Thanks
- tristaanogre6 years agoEsteemed Contributor
What it looks like is that, after you click on the control, the list items are not necssarily visible on screen. Before you click on them, try calling "scrollIntoView" on the object (I'm assuming this is a web application). That will make sure that it is visible on screen before any attempts to act on it are executed.
- russelld6 years agoContributor
No, "scrollIntoView" is not available. Its a desktop application not a web application.
- SaravanaKumar_N6 years agoContributor
So now you are able to find the item. And did you get a chance try this way..
Can you check ListItem object has any methods like 'Focus' ? (you can check in the object browser)
If available, you can do..
listItems[i].Focus();
Delay(500); // delay may be needed, if not remove it
listItems[i].Click();
- russelld6 years agoContributor
Thanks
Focus is availble with the parent two levels up. The attached is the properties I got to work with
Related Content
- 12 months agolokwk216
- 11 years agoRavik
- 6 years agofunmay
- 12 years agositasrikanth
Recent Discussions
- 2 days agoGane195