c# - WaitForControlEnabled() throws UITestControlNotFoundException -


i'm waiting control enabled this:

control.waitforcontrolenabled(60000); // timeout in 60 seconds 

however, ten seconds in method throw uitestcontrolnotfoundexception:

test method mytest threw exception: automation playback engine not able find button &next > in - window &next >. additional details: technologyname: 'msaa' name: 'next >' controltype: 'button' microsoft.visualstudio.testtools.uitest.extension.uitestcontrolnotfoundexception     @ microsoft.visualstudio.testtools.uitesting.playback.mapcontrolnotfoundexception(comexception ex, iplaybackcontext context)     @ microsoft.visualstudio.testtools.uitesting.playback.mapandthrowcomexception(comexception innerexception, iplaybackcontext context)     @ microsoft.visualstudio.testtools.uitesting.playback.mapandthrowexception(exception exception, iplaybackcontext context)     @ microsoft.visualstudio.testtools.uitesting.playback.mapandthrowexception(exception exception, string queryid)     @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.findfirstdescendant(string queryid, boolean expanduielementwhilesearching, int32 searchtime)     @ microsoft.visualstudio.testtools.uitesting.searchhelper.getelement(boolean usecache, isearchargument searcharg)     @ microsoft.visualstudio.testtools.uitesting.searchhelper.search(isearchargument searcharg)     @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.findinternal()     @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.findcontrolifnecessary()     @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.waitforcontrolreadyprivate(int32 millisecondstimeout, boolean dologging)     @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.waitforcontrolenabledprivate(int32 millisecondstimeout)     @ microsoft.visualstudio.testtools.uitesting.uitestcontrol+<>c__displayclass4a.<waitforcontrolenabled>b__49()     @ microsoft.visualstudio.testtools.uitesting.codeduitestmethodinvoker.invokemethod(func`1 function, uitestcontrol control, boolean fireplaybackerrorevent, boolean logasaction)     @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.waitforcontrolenabled(int32 millisecondstimeout)      error hresult e_fail has been returned call com component.     system.runtime.interopservices.comexception         @ microsoft.visualstudio.testtools.uitest.playback.engine.iscreenelement.findalldescendants(string bstrqueryid, object& pvarreskeys, int32 creskeys, int32 nmaxdepth)         @ microsoft.visualstudio.testtools.uitest.playback.screenelement.findallscreenelement(string queryid, int32 depth, boolean singlequeryid, boolean throwexception, boolean resetskipstep)         @ microsoft.visualstudio.testtools.uitest.playback.screenelement.findscreenelement(string queryid, int32 depth, boolean resetskipstep)         @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.findfirstdescendant(string queryid, boolean expanduielementwhilesearching, int32 searchtime) 

my questions are:

  • why doesn't waitforcontrolenabled(60000) wait whole 60 seconds?
  • why throw uitestcontrolnotfoundexception though not mentioned in msdn doc?

edit: have used waitforcontrolexist() directly before waitforcontrolenabled(), waitforcontrolenabled() still throws same exception, makes no sense me:

control.waitforcontrolexist(60000); control.waitforcontrolenabled(60000); 

if waitforcontrolexist() returns, means ui element found. how can not found after?

to wait until time specified in waitforcontrolenabled() method, top hierarchy of controls should exist or actual control must exist or in disabled state, otherwise smart search engine fails find waiting control , throws exception. if control not there can try waitforcontrolnotexist() method wait until control exist, because found same issue in test cases, here solution wait control hour of time until exit or enabled.

        bool iscontrolexist= uiwaitingbutton.waitforcontrolenabled();          while (!iscontrolexist)         {             try             {              uiwaitingbutton.searchconfigurations.add(searchconfiguration.alwayssearch);              uiwaitingbutton.setfocus(); // setting focus on button              iscontrolexist= uiwaitingbutton.waitforcontrolexist(100);             }             catch (exception ex)             {                // possibly exception setfocus() method call                 // handle exception, write log message                                }          }          // perform button click after find control         // click 'save' button         mouse.click(uiwaitingbutton, new point(100,100)); 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -