Page 1 of 1

Problem with contents of enumerator For Each loop (web app)

Posted: Thu Jan 09, 2014 6:30 pm
by szohar
I have a Ranorex test suite that tests a web-based app using different Windows browsers. There's a separate mobile version of this app, and there is no need for this app to be deployed on other non-Windows operating systems such as Apple/Mac or Linux, so we're only worried about this app working on IE, Firefox, and Chrome at this time.

The overall (simplified) workflow of the Ranorex test suite is as follows:

1. Setup: Open the browser and bring up a fresh form.
2. Start the test case, which is bound to an Excel file containing ~15 data records to enter into the form.
---2a. Enter the information into the form.
---2b. Verify that the form was processed correctly.
---2c. Bring up a fresh form for the next iteration.
3. Teardown: Close the browser.

Within the test case, there is user code that contains a loop that searches for the data record's country within a dropdown list box on the form, using a span tag enumerator:

Dim VarMatchFound as Boolean = False
Do Until VarMatchFound = True
---For Each SpTag as SpanTag In MyRepo.FormName.SelectCountry.Find(".//div[#'cusel-scroll-country']/span")
------Select Case True
---------Case SpTag.InnerText = VarCountry
------------VarMatchFound = True
------------Exit Do
---------Case VarCountry Like "*Col[o,u]mbia" And SpTag.InnerText Like "*Col[o,u]mbia"
------------VarMatchFound = True
------------Exit Do
------End Select
------MyRepo.FormName.SelectCountry.PressKeys("{down}")
---Next SpTag
Loop

The dropdown list box is a custom 3rd-party control. When the form is freshly loaded, the initial text value for the country is United States, because most of the users are based in the U.S. However, if the user clicks on the list box's arrow down, the dropdown list box actually lists the countries in alphabetic order if the user scrolls the list of countries in order.

The loop logic listed above works beautifully in Firefox, Chrome, and even Safari for Windows. It also worked fine in IE 10. However, there's a weird problem when testing this using IE11, as the test proceeds through each iteration of the loop.

The first iteration of the loop always works beautifully.

The second iteration of the loop sometimes does not load the information from the list box into the SpTag enumerator. When that happens, the contents of the SpTag.InnerText ends up being null.

I created a work-around that gets around this problem, but it is ugly and slows things down:

Dim VarMatchFound as Boolean = False
Do Until VarMatchFound = True
---For Each SpTag as SpanTag In MyRepo.FormName.SelectCountry.Find(".//div[#'cusel-scroll-country']/span")
------Select Case True
---------Case SpTag.InnerText = VarCountry
------------VarMatchFound = True
------------Exit Do
---------Case VarCountry Like "*Col[o,u]mbia" And SpTag.InnerText Like "*Col[o,u]mbia"
------------VarMatchFound = True
------------Exit Do
---------Case MyRepo.FormName.SelectCountry.InnerText = VarCountry
------------VarMatchFound = True
------------Exit Do
---------Case VarCountry Like "*Col[o,u]mbia" And MyRepo.FormName.SelectCountry.InnerText Like "*Col[o,u]mbia"
------------VarMatchFound = True
------------Exit Do
------End Select
------MyRepo.FormName.SelectCountry.PressKeys("{down}")
---Next SpTag
Loop

I've run this workaround in debug mode to see if I could find some kind of pattern as to which iterations would work correctly and which iterations used the workaround cases. After running repeated tests, I have not observed any particular patterns. It is impossible to predict which iterations will load the enumerator, and which ones will not.

Can anyone help me figure out why the original code is unable to load the enumerator properly for each iteration in IE 11?

Thanks in advance,

SZ

Re: Problem with contents of enumerator For Each loop (web app)

Posted: Tue Jan 14, 2014 6:45 pm
by BernhardS
Hello szohar,

thank you for the description, but i am afraid that I don't understand the problem exactly.
Is it possible to post a Ranorex Snapshot from the element in IE11 during the second iteration?
Can you please also post the Ranorex report file and some screenshots in order to analyze the issue?
Thank you!

Regards,
Bernhard

Re: Problem with contents of enumerator For Each loop (web app)

Posted: Wed Jan 22, 2014 6:24 pm
by szohar
I was temporarily diverted to a different project for a little while, but I'm now working on this project again. Looking at the project with fresh eyes, I made some improvements, but the problem is still happening. Anything I post has to be carefully edited, because the application has some proprietary information, so I also had to spend some time coming up with information that can be shared.

I will post a little updated information about the problem separately, but I would still prefer to send more detailed information such as the Ranorex report and screen captures of the relevant section of the repository directly to Ranorex - should I use the [email protected] email address to send that information?

Thanks,

SZ

Re: Problem with contents of enumerator For Each loop (web app)

Posted: Wed Jan 22, 2014 6:37 pm
by szohar
Dim VarMatchFound As Boolean = False
Do Until VarMatchFound = True
---For Each SpTag As SpanTag In repo.FormName.SelectCountryScroll.Find(".//div[#'cusel-country']/span")
------If String.IsNullOrEmpty(SpTag.InnerText) = False Then
---------If SpTag.InnerText.TrimEnd = VarCountry Then
------------Report.Info("User", "Country matched using primary comparison logic")
------------VarMatchFound = True
------------SpTag = Nothing
------------Exit Do
---------End If
------ElseIf repo.FormName.CountryDivText.InnerText.TrimEnd = VarCountry.TrimEnd Then
---------Report.Info("User", "Country matched using backup comparison logic")
---------VarMatchFound = True
---------SpTag = Nothing
---------Exit Do
------End If
------repo.FormName.SelectCountryScroll.PressKeys("{down}")
---Next SpTag
Loop

Re: Problem with contents of enumerator For Each loop (web app)

Posted: Tue Feb 11, 2014 5:04 pm
by Support Team
Hi szohar,

I am not exactly sure if you were able to fix your issue because I didn't get any further information about your issue.

Regards,
Bernhard

Re: Problem with contents of enumerator For Each loop (web app)

Posted: Tue Feb 11, 2014 5:07 pm
by szohar
Actually, I asked whether I should send the additional information about the problem to the [email protected] email address, because I am uncomfortable posting any more detailed information to the public forum.

Re: Problem with contents of enumerator For Each loop (web app)

Posted: Wed Feb 12, 2014 6:19 pm
by Support Team
Hi szohar,

Sure, just send an email to [email protected].

Regards,
Bernhard