Methods not working in Automation but Working in TestMethods
I am trying to automate FISERV DNA windows application and most of the time, test control methods work on most of the controls I interrogated. But in the automation, the same methods just fails. No error or anything. Tried re-interrogating controls, tried checking match rules and it all seems to be fine.
This is not the first time I am facing this issue. I had posted similar questions before and there was no satisfactory reply.
Why is it that Testcontrolmethods work and the same methods in automation fail? this doesn't make any sense to me.
It's difficult to analyze without checking the log and automation on your side, but I think it might be a timing problem.
Maybe you want to check the events happened in the page.
How do I make sure a window is completed loaded? I tried waitforcreate and it's not reliable most of the times. I have seen other users complaining about the same. Is there a method to make sure that a window has finished loading other than Waitforcreate or IsCreated??
Sometimes, after the html file being loaded, some js code changes the document dynamically which may not be detected by the adapter automatically. That's maybe one reason why some time waitforcreate doesn't work. Checking whether there's any ui control being changed or js function called at that timing may help.
I think waitforcreate can do the work, it just need to be called at a right control.
TestMethods should work the same at Runtime. I have seen some developers "corrupt" the test by clicking the page or interacting with it in some way, allowing the test method to work where it otherwise would not. This also may be a timing issue as jiaol alluded to.
WaitForCreate is a loop until a control's IsCreated property is true. If the control is already created, it will return true immediately and not really wait for anything. If you are using a later version of 19.1, you have the option to enable the Robot Inspector which will allow you to execute the test methods at runtime. If it is a timing issue, then making whatever methods you are calling come from a windows form button click that you'd trigger manually would tell you that (i.e. they would work if you called it presumably after the page finished).