Ask a Question

How do I setup my drop-down window to select the listItem?

russelld
Contributor

Re: How do I setup my drop-down window to select the listItem?

See the following attachments...Thanks

SaravanaKumar_N
Contributor

Re: How do I setup my drop-down window to select the listItem?

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.

russelld
Contributor

Re: How do I setup my drop-down window to select the listItem?

The dropdown gets clicked but it can't find the 'listitem' because of the scrollbar.

 

 

SaravanaKumar_N
Contributor

Re: How do I setup my drop-down window to select the listItem?

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)

russelld
Contributor

Re: How do I setup my drop-down window to select the listItem?

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_N
Contributor

Re: How do I setup my drop-down window to select the listItem?

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
      }

}
russelld
Contributor

Re: How do I setup my drop-down window to select the listItem?

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

tristaanogre
Community Hero

Re: How do I setup my drop-down window to select the listItem?

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
russelld
Contributor

Re: How do I setup my drop-down window to select the listItem?

No, "scrollIntoView" is not available.  Its a desktop application not a web application.

SaravanaKumar_N
Contributor

Re: How do I setup my drop-down window to select the listItem?

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();

 

cancel
Showing results for 
Search instead for 
Did you mean: