Forum Discussion

RUDOLF_BOTHMA's avatar
RUDOLF_BOTHMA
Community Hero
7 years ago

Window is invisible and thus cannot be activated

Morning all.  First up, the error:

  I put text into a textbox in script.  In the Picture you can see that the page is just fine with nothing in the way.  I have extensive code to do existance checks etc. before I even get here, so I'm pretty sure that I have the object.  Code (roughly) about as follows

 

function SetTex(TextBoxControl) //Textboxcontrol is a table  The textbox is inside this table - DevX
{
var textContainer = null;
if(aqObject.IsSupported(TextBoxControl,"ObjectType")) //You never know...
	{
		if(aqObject.GetPropertyValue(TextBoxControl,"ObjectType")== "Table") //we got the outer table.  Execute waits
		{
			var waitCell = ExecuteWait("CELL",TextBoxControl,[0,0]);	//helper function that just does a WaitNNN - helps ensure everything is ready		
			textContainer = waitCell.FindChildEx("ObjectType",objectType,1,true,5000);	
		}
		else //We probably got the textbox itself as mapped object.  Do a FindEx rather than findchildex
		{
			textContainer = TextBoxControl.FindEx("ObjectType",objectType,1,true,5000);		
		}
	}
	else //most likely the object doesn't exist
	{
		Log.Error("Mapped TextBox object does not have a valid object type.","",pmNormal,"",GetPagePicture());
		return;
	}
}
if(!textContainer.WaitProperty('Exists', true, 5000))
	{
		Log.Error("Unable to locate text container in textbox control [" + TextBoxControl.MappedName + "] in the allocated time","",pmNormal,GetPagePicture());
		return;	
	}	
  
	if(!textContainer.WaitProperty('Visible', true, 5000))
	{
		Log.Error("Text container in textbox control [" + TextBoxControl.MappedName + "] is not visible","",pmNormal,GetPagePicture());
		return;	
	}		

textContainer.SetText("");
}

If we reach the SetText, the texbox both exists and is visible, but then I get the error. Not always, mind you. And the next thing it does is set the text as expected. The test continues correctly, but it fails because of this error. Thoughts?

  • Bah !  I think I know what it is !

     

    There's this post, written by me, not to long ago on a Smartbear Functional Web Testing board near you ! It explains that DevX has a quirk with setting text.  SetText() is unreliable - TestComplete can't alway find it and DevX doesn't register changes.  .Keys() however works fine...

     

    There's no facepalm emoticon..

     

    Quick, someone repost my post so I can mark it as the accepted solution.  I can't mark my own answer as a solution if I was just being a bit slow :smileytongue:

  • AlexKaras's avatar
    AlexKaras
    7 years ago

    Hi,

     

    > SetText() is unreliable [...]

    Not that it is unreliable... It just works differently when compared to .Keys().

    .SetText() tries direct assignment to the property that keeps the value of the given object. This should work much faster than .Keys(), but the problem is that a lot of controls do not process direct property assignment but expect the value to be modified via either keypresses or be pasted from the clipboard.

    On the contrary, .Keys() method puts key press messages into the control's message queue. Exactly like the OS does when end-user types on the keyboard. Then control's message routine extracts and processes keycodes (and all other codes like mouse events etc.) from the queue and either processes them or relays to the parent message queue. This process is obviously slower but corresponds to the regular developers' expectations.

     

     

  • Bah !  I think I know what it is !

     

    There's this post, written by me, not to long ago on a Smartbear Functional Web Testing board near you ! It explains that DevX has a quirk with setting text.  SetText() is unreliable - TestComplete can't alway find it and DevX doesn't register changes.  .Keys() however works fine...

     

    There's no facepalm emoticon..

     

    Quick, someone repost my post so I can mark it as the accepted solution.  I can't mark my own answer as a solution if I was just being a bit slow :smileytongue:

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      > SetText() is unreliable [...]

      Not that it is unreliable... It just works differently when compared to .Keys().

      .SetText() tries direct assignment to the property that keeps the value of the given object. This should work much faster than .Keys(), but the problem is that a lot of controls do not process direct property assignment but expect the value to be modified via either keypresses or be pasted from the clipboard.

      On the contrary, .Keys() method puts key press messages into the control's message queue. Exactly like the OS does when end-user types on the keyboard. Then control's message routine extracts and processes keycodes (and all other codes like mouse events etc.) from the queue and either processes them or relays to the parent message queue. This process is obviously slower but corresponds to the regular developers' expectations.

       

       

      • RUDOLF_BOTHMA's avatar
        RUDOLF_BOTHMA
        Community Hero

        a lot of controls do not process direct property assignment but expect the value to be modified via either keypresses or pasting from the clipboard.

         


        Absolutely the case with DevX