質問

I have application "Application" , which have same autorization service as skype, QQ etc (You must log using yours login/password) I need to test some functionality in settings of this application, so I`m using testcomplete :

  1. I need tu run application
  2. Go to settings
  3. Change something
  4. Save

And its quite simple. But if you are logged of, I need to reproduce such scenario:

  1. run application 1.1. if logged of - log using (testlogin/testpassword)
  2. Go to settings
  3. Change something
  4. Save

How I can reproduce such functionality in TestComplete? I`m newbie with it so I need help :) Thanks

役に立ちましたか?

解決

Make your test check whether the login window is displayed. You can do this using one of the Wait* methods. If the login window is displayed then call a test routine/keyword test that will perform a login and then continue the general test flow.

...
var loginWindow = Sys.Process("Application").WaitWinFormsObject("loginDialog", 3000);
if (loginWindow.Exists) {
  doLogin();
}
...
function doLogin()
{
  // perform login
}

他のヒント

While your answer is totally right, I'd like to know if this is possible:

If the loginWindow does not exist, TC gives an error, is it possible to ignore this error and keep it out of the log besides locking the log or disabling it?

Like in Java or C#:

if(object.Exists)
  do something;
else
  do other thing;

this throws an error in TC and I don't want it to because I'm already checking for the existence of the object...

You cannot use a method on a object that is not there.

Workaround would be to first check for an object and then to use the Exists method like so..

if (object && object.Exists) {
    // doSomething
} else {
    // doSomethingElse
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top