Input values not up updating dynamicly

Bug reports.
bellew.mike
Posts: 10
Joined: Wed Jan 14, 2015 1:20 pm

Input values not up updating dynamicly

Post by bellew.mike » Tue Jul 28, 2015 4:16 pm

Hi Ranorex,

I am having some issues with the InputTag.Value property when the value is updated dynamically (via javascript)

I have knocked up an example of this using this html page and test code:

Code: Select all

<!DOCTYPE html>
<html>
	<body>
		<input id="textbox" type="text" />
		<script>
			window.setTimeout(enterText, 10000);
			function enterText() {
    			document.getElementById('textbox').value = 'test';
			}
		</script>
	</body>
</html>

Code: Select all

        void ITestModule.Run()
        {
			//Open Chrome
			Host.Local.OpenBrowser(Directory.GetCurrentDirectory() + "\\testpage.html", "iexplore", "", false, true);
            
			//Uncomment this to make test pass
			//Delay.Milliseconds(15000);
			
            //Setup Elements
            WebDocument dom = new WebDocument(Host.Local.FindSingle("/dom[@page='testpage.html']", Duration.Parse("5000")));
            InputTag input = new InputTag(dom.FindSingle(".//input[#'textbox']"));
            
            //Set up stopwatch for loop
            Stopwatch sw = new Stopwatch();
            sw.Start();
            
            //Wait for input value to be "test"
            //This should happen after 15 seconds
            //Bomb out after 60 seconds using sw
            do{
            	Report.Info(input.Value);
            }while(input.Value != "test" && sw.ElapsedMilliseconds < 60000);
            
            //End Test
            if(input.Value == "test"){
				Report.Success(input.Value);
            }else{
            	Report.Failure(input.Value);
            }
        }
This has hindered us twice in the past:

1. A page loads slightly slowly we wait for the text in a text box to be a certain value. If we check too quickly we forever get null

2. A hidden input box with a span controlling it (devs said this was a styling thing) when the span is clicked the inputbox should update to checked, but didn't.

Any workarounds?

Regards,
Mike

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Input values not up updating dynamicly

Post by krstcs » Tue Jul 28, 2015 4:23 pm

This is not a bug with Ranorex.

The issue is that you will need to put in a delay or wait for the page to return a status of 'complete' before you start checking for values. If you check to quickly then Ranorex will see a null or other weird value.

Understand that Ranorex will go AS FAST AS IT CAN. You as a human will always wait for the page to fully complete, Ranorex won't unless you tell it to.

My suggestion is that you add the following to your /dom object (the top object in your repo):

Code: Select all

 and @state='complete'
So your full XPath for the domain might look like:

Code: Select all

/dom[@domain='my.domain.com' and @state='complete']
This tells Ranorex to only find the webdocument (dom) if it returns a state of complete, meaning all scripts and elements have been loaded.

There are some pages that update the status and then continue to run more scripts causing the page to return to an incomplete state, so you might want to add some 2-5 sec delays before some validations so the page has time to fully load.
Shortcuts usually aren't...

bellew.mike
Posts: 10
Joined: Wed Jan 14, 2015 1:20 pm

Re: Input values not up updating dynamicly

Post by bellew.mike » Wed Jul 29, 2015 9:19 am

Our app has multiple iframes and as you said, does run scripts after the page has fully loaded.

However my issue is not that it returns an odd value the first time I check it. That I understand. The issue is that it never updates when I continue to check it over the next 45 seconds?

Cheers for the response,
Mike

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Input values not up updating dynamicly

Post by krstcs » Wed Jul 29, 2015 3:46 pm

OK, you didn't mention iframes in the initial post, so that might be the issue.

With Ranorex and RanoreXPath you MUST include references to ALL iframe elements in the R-XPath. Otherwise Ranorex may not find the final element in the path (or any element after the iframe). It's just how iframes work in the dom.

So, I suggest adding all the iframes to your path (in the right spots, of course) and seeing if that helps.
Shortcuts usually aren't...

bellew.mike
Posts: 10
Joined: Wed Jan 14, 2015 1:20 pm

Re: Input values not up updating dynamicly

Post by bellew.mike » Wed Jul 29, 2015 4:04 pm

The iframes are in the path, another nice try. If I add a 1 second wait as the page loads before we look for the element the first time the test passes.

Regards,
Mike

bellew.mike
Posts: 10
Joined: Wed Jan 14, 2015 1:20 pm

Re: Input values not up updating dynamicly

Post by bellew.mike » Wed Aug 19, 2015 12:27 pm

If you run the example html page and test code I provided you can see the issue for yourself with no iframes involved.

Regards,
Mike