Dropdown and AJAX

Ranorex Spy, Recorder, and Studio.
Razzil
Posts: 2
Joined: Tue Apr 07, 2015 3:09 pm

Dropdown and AJAX

Post by Razzil » Tue Apr 07, 2015 3:35 pm

Hey there,

I'm evaluating ranorex as a tool for our company and I'm stuck at a little problem.
We use asp.net for our websites.

We have two dropdownlist(group + subgroups) on the page. The second one contains elements depent on the first dropdown. If you chose something on the first dropdown, the second one loads the data and you can chose an element(subgroup).
As a user it works without a problem. In Ranorex it works in 90% of the time. Sometimes it doesn't set the subgroup. I think the problem is, Ranorex is trying to set the subgroup before the data is loaded via AJAX. Is there a way to solve this problem? Can I say Ranorex in it has to wait? and how?

Both dropdown are visible/enable at the beginning, just the second one doesn't contain any data. The sourcecode looks something like this:

protected void GroupChanged(object sender, EventArgs e)
{
PrepareSubGroups();
}

private void PrepareSubGroups()
{
ddSubGroups.Items.Clear();
ddSubGroups.DataSource = ....;
ddSubGroups.DataBind();
}

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

Re: Dropdown and AJAX

Post by Support Team » Wed Apr 08, 2015 9:09 am

Hello Razzil,

Welcome to our forum.

In order to solve the issue you will need to check whether the element is in its correct state, e.g., using a validation. Please create a Ranorex snapshot of the fully loaded subgroup element, this would allow us to provide further help.

Regards,
Robert
.
Image

Razzil
Posts: 2
Joined: Tue Apr 07, 2015 3:09 pm

Re: Dropdown and AJAX

Post by Razzil » Wed Apr 08, 2015 9:57 am

Hey there,

thanks for your response.
Here are the requested files. First one with loaded elements und second one without any element.

I know there is a validation for the dropdown, but I didn't find anything like:
"Wait just the subGroup has Element > 0"
Attachments
SubGroupEmpty.rxsnp
(205.98 KiB) Downloaded 59 times
SubGroup.rxsnp
(468.83 KiB) Downloaded 59 times

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

Re: Dropdown and AJAX

Post by Support Team » Thu Apr 09, 2015 8:42 am

Hello Razzil,

I'm not sure how you select the entries within your drop down element, but you could try to use the following:
var select = repo.BettyBossiNewTraffic.Ctl00CpDdUnterGruppe;	
        	var option = select.FindSingle(".//option[@value='10']", 10000);
        	option.As<OptionTag>().Select();
Hope this helps.

Regards,
Robert
.
Image