Select control not popping up message when listitem is click

Ask general questions here.
User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Select control not popping up message when listitem is click

Post by Aracknid » Tue Jul 17, 2012 4:43 pm

Using Ranorex 3.3.1 on Windows XP with IE8.

I've got a select control that when dropped open presents a list of items to pick. When you pick an item, it sets the select control to this item and then pops up a message warning you about something you need to do in the program. When this control is popped open, I can spy on it using CTRL+WIN and see that it's a container with listitems. However, when focus on the app is lost, the popup closes and I cannot do much in Spy since it's lost the controls and I cannot save a snapshot as a result.

In my code, I click the select an iterate through the items and set the item's select value to true (because trying to click it doesn't actually work). Works fine. However, the message box does not appear. I've run into this in the past with my old automation tool and it was because an event was not being fired.

Since in my code I'm not actually "clicking" the option, I figure this is the reason it is not firing the event.

So any thoughts on what is happening and how to resolve it?

Here's the code I'm using:
MySelectTag = Adapter.Create(Of Ranorex.SelectTag)(MyControl.Element)
MySelectTag.Click() 'open the popup

For Each MyOption In MySelectTag.Options
    'Debug.Print(MyOption.InnerText)
    If MyOption.InnerText = sValue Then
        MyOption.Selected = True
        MySelectTag.Click() 'close the pop up
        bFound = True
        Exit For
    End If
Next
And here is what I see in Spy (as mentione, I cannot save a snapshot since on focus loss, the popup disappears)
spy screenshot.JPG
spy screenshot.JPG (81.11 KiB) Viewed 1849 times
Thanks,

Aracknid.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Select control not popping up message when listitem is click

Post by Ciege » Tue Jul 17, 2012 7:36 pm

1) try this to get Spy to find your elements... http://www.ranorex.com/forum/ranorex-sp ... -t914.html

2) Yes, it would appear that the event is not firing since you are not clicking on the object. You mention that click doesn't work... Any reason why? That would be what I would solve so that the event is properly fired.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Select control not popping up message when listitem is click

Post by Aracknid » Tue Jul 17, 2012 8:24 pm

If I change my code from "MyOption.Selected = True" to "MyOption.Click", the click doesn't work, but since the select does, I know I have the right list item. I guess until I hear about any other ways to work with this, I'll keep playing around with it.

I was not aware of the Scroll Lock feature, thanks for pointing it out. However in this case it doesn't add value (to me), other than allowing for the snapshot to send info to support if they want it. Live or Snapshot, I still see the same info.

Aracknid

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Select control not popping up message when listitem is click

Post by Ciege » Tue Jul 17, 2012 8:30 pm

Hmm, so using Scroll to get the current snapshot does not show your elements to give you an idea of what to work with?

When you say the Click doesn't work... do you get an error? Does it click in the wrong place? Can you elaborate on this issue so we can try to solve it...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Select control not popping up message when listitem is click

Post by Aracknid » Tue Jul 17, 2012 8:51 pm

Ciege wrote:Hmm, so using Scroll to get the current snapshot does not show your elements to give you an idea of what to work with?
Actually, it does show the elements. What I meant was that it also showed it even when I didn't press scroll. Before using Scroll Lock to take a snapshot, it wouldn't let me save the snapshot. So You've helped me to resolve that issue so I can send something to support if they want it.
Ciege wrote:When you say the Click doesn't work... do you get an error? Does it click in the wrong place? Can you elaborate on this issue so we can try to solve it...
No error. Looks like it is trying to click, and probably clicking in the wrong place. Looks like the control is doing a bit of moving around (the dialog in which it appears is scrollable so I think it's moving it). I'll have to look at it more. To be honest, it's not my issue. Someone that works for me is having it and Ranorex is newer to them than to me, so I'm trying to help them out. I'm playing a bit of middle man here...

Aracknid.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Select control not popping up message when listitem is click

Post by Ciege » Tue Jul 17, 2012 9:51 pm

Hmmm, well since it's a list item issue, maybe the list item is not visible in the current list (i.e. one would need to scroll up or down to actually click on it) and Ranorex isn't performing the scroll properly...

Something to try would be to write your own (short/easy) list item selector method. Have it use the keyboard. Once the list is open, keyboard press CTRL-HOME to get to the top of the list. Get the currently highlighted item, if it is not the one you want press the down arrow, and re-evaluate. When the one you want is highlighted keyboard press ENTER.

Pressing ENTER should have the same effect as clicking the item and should trigger the fire event.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Select control not popping up message when listitem is click

Post by Aracknid » Tue Jul 17, 2012 10:00 pm

Yeah, I got a lot of code like that already I can use (Silverlight needs a lot of keyboard navigating) so I can look into this.

Another question, related to what I'm seeing as I try to debug this. the screen shot is from IE 8 on Windows XP. So the tree shows Container -> List -> Listitems.

I'm working in IE9 on Windows 7 and the same place shows as Container -> Listitems... (no list element)

Does that make sense?

I was tring to write code to iterate through the list.items, but since there is no list I cannot do that. and the container won't allow me to look at list items either... And it's very frustrating to work with because I cannot step through the code because as soon as the IDE gets focus the popup disappears...

Oh well, I'll approach with a healthy and refreshed mind and attitude tomorrow. Going home now.

Aracknid

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Select control not popping up message when listitem is click

Post by artur_gadomski » Wed Jul 18, 2012 6:48 am

I don't know if it will work for lists or web, but sometimes for edit boxed in windows applications pressing Tab after changing text helps with triggering events. Of course Clicking would be a lot better. Maybe Select then Click?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Select control not popping up message when listitem is click

Post by Support Team » Wed Jul 18, 2012 2:53 pm

Hi,

First of all I want to mention something about the right tracking of selection tags and option tags, respectively. You always need to track the selection tag (CTRL+WIN) BEFORE clicking on it- for additionally snapshot press SCROLL - and then expand the underlying elements in the spy manually to get to the option tags.
Otherwise you have the problem - as shown in your screenshot - that the elements are listed outside of the website-structure.

I have two ways which might solve your problem
1.
Performing Click actions isn't a recommended way to select a special Option tag.
A better way is to select it with
optionTag.Selected = true;
As already mentioned, the drawback of this is the loss of "firing the event".
This you can compensate with calling your popup message manually with the following code line (assuming a java script for your popup):
webDocument.ExecuteScript("The java script code chunk");
2.
I also tried it with the clicking action and it went pretty well:
First track your tag as described above. Then write following lines of code:
SelectTag someSelectTag = "Drag'n'Drop from spy";
someSelectTag.Click();
OptionTag yourTag= "Drag'n'Drop from spy";
yourTag.Click();
Hope this helps,
Larissa
Ranorex Support Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Select control not popping up message when listitem is click

Post by Aracknid » Wed Jul 18, 2012 4:01 pm

Is there a way to fire the "onchange" event? I'm trying to make this generic, and I don't want to specifically execute a script that is only for this one control, that might need a different script when in some other place in the app, and most times it doesn't need to execute anything?

Is there a way to programmatically extract the name of the script that should be executed, if one needs to?

What I'm getting at is that I can use the IE F12 function to launch the IE tool that allows me to get info on something. And for this particular control, there is an "onchange" event that looks like this, and I don't know what script it calls...

onchange="OnOpportunityChange(this,true);MetadataCheckField(this,true);"

When I view the source for this page, there is a function called "OnOpportunityChange", so I tried to do this;

MyWebDoc.ExecuteScript("OnOpportunityChange")

But nothing happened, so I don't know if I'm doing it right.

Thanks,

Aracknid

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Select control not popping up message when listitem is click

Post by Support Team » Thu Jul 19, 2012 8:29 am

Hi,

I tried to reproduce your problem but in the examples I did it worked well.
It would be very helpful if you send me a link to the website you tried on.
Thanks,

Larissa
Ranorex Support Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Select control not popping up message when listitem is click

Post by Aracknid » Thu Jul 19, 2012 2:38 pm

Sorry, but it's not a web site. It's a client/server app that uses a browser to connect to the server. It's not accessible externally.

I think the reason it didn't work was because I need to pass it parameters, but I don't know what to pass it for "this". The "this" in this particular case is supposed to be the select control, but I cannot pass it the Ranorex selecttag since it is not the expected object.

I tried: MyWebDoc.ExecuteScript("OnOpportunityChange(" & MySelectTag.Name & ",true)")

because it needs a string, but that just gave me a web page error.

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Select control not popping up message when listitem is click

Post by Aracknid » Thu Jul 19, 2012 2:53 pm

Oh, I see what I've done wrong. I made a silly mistake. I forgot to put quotes arounf the name of my control. If I do it properly it does work. Here's what I did to fix it:

MyWebDoc.ExecuteScript("OnOpportunityChange(""" & MySelectTag.Name & """,true)")

This now correctly fire the event and the message box appears.

BUT now I have a new problem. When the message box appears, my script it frozen while waiting for a response. I've run into this in the past with other automation tools, and in that other tool we were not able to write scripts this way and had to find an alternative. I do have an alternative, which just using keyboard keys to select it and Enter to 'click' on it.

I was just wondering if there is a solution to this here?

Thanks,

Aracknid

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Select control not popping up message when listitem is click

Post by Support Team » Fri Jul 20, 2012 1:54 pm

Hi,

I don't know if I get you right, but isn't it the correct behavior of the message box to block the other events until it is served?

Please rewrite your question for me.

Thanks,
Larissa
Ranorex Support Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Select control not popping up message when listitem is click

Post by Aracknid » Fri Jul 20, 2012 2:26 pm

Hi,

I'm writting this code in VS2010. The code I've written sets the selected state of option item to true, then it executes the script which causes a message box to appear. When the popup appears, how can I automate which button to click in the message box when the script is frozen and not responding until I manually click on the button?

In the debugger, it doesn't execute the line of code that executes the script and then return and move to the next line UNTIL the popup is handled...

Aracknid