Есть отличная удаленная работа для php+codeception+jenkins+allure+docker спецов. 100% remote! Присоединиться к проекту

TestComplete 9 ввод рандомных величин.


(FreeMan) #1

TestComplete 9 ввод рандомных величин.

Нужно в срочном порядке освоить TestComplete. Поэтому вопрос, как нужно задать Value для операции Keys, что бы вводились случайные данные? Как из экселевского(или еще откуда нибудь) файла можно запрашивать случайные(или по порядку, но каждый раз разные) данные, например логин и пароль для логин теста.

 

P.S. - и еще вопрос если тестируемая программа уже запущена выдает - There is (are) 1 running instance(s) of "C:\Program Files (x86)\ProAct8u5b12\p8.exe". New instances will not be launched.    11:01:22    Highest      

Как обойти это ограничение? Версия Demo.


(FreeMan) #2

Вот этот тест прекрасно работает, но только один раз, так как "рандомное" число всегда одно и тоже.

 

Function getRandomNumber
  getRandomNumber = Round(rnd() * 500)
End Function
Sub Test1
  Dim p8
  Dim wndp89c000000
  Dim p89c000000
  Dim wndAccruals
  Dim wndp89c0000002
  TestedApps.p8.Run
  Set p8 = Aliases.p8
  Call p8.wndLogin.Keys("з[BS]~![ReleaseLast][ReleaseLast]login[Tab]password[Enter]")
  Set wndp89c000000 = p8.wndp89c000000
  Delay (5000)
  Call wndp89c000000.MainMenu.Click("System|[1]|[0]")
  Set p89c000000 = wndp89c000000.p89c000000
  Set wndAccruals = p89c000000.wndAccruals
  Call wndAccruals.Click(27, 47)
  Set wndp89c0000002 = p89c000000.wndp89c000000
  Call wndp89c0000002.Keys(getRandomNumber)
  Call wndp89c0000002.Click(162, 377)
  Call wndp89c0000002.Keys("123")
  Call wndp89c0000002.Click(302, 385)
  Call wndp89c0000002.Keys("123")
  Call wndp89c0000002.Click(320, 421)
  Call wndAccruals.Click(400, 419)
  Call wndp89c000000.MainMenu.Click("File|[1]")
End Sub

Подскажите, как получать каждый раз разное число?

 


(apetrovskiy) #3

http://msdn.microsoft.com/en-us/library/f7s023d2(v=vs.80).aspx

 

For any given initial seed, the same number sequence is generated because each successive call to the Rnd function uses the previously generated number as a seed for the next number in the sequence.

Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer.

To produce random integers in a given range, use the following formula.

 
randomvalue = CInt(Int((upperbound - lowerbound + 1) * Rnd() + lowerbound))

 

This example uses the Rnd function to generate a random integer value in the range from 1 to 6.

 
' Initialize the random-number generator.
Randomize()
' Generate random value between 1 and 6.
Dim value As Integer = CInt(Int((6 * Rnd()) + 1))
 

успешный запрос: http://goo.gl/2rSCA

 


(apetrovskiy) #4

http://support.smartbear.com/viewarticle/30623/

 

Count

Specifies the number of application instances to be run. If Count is less than 0, the method will run as many instances as the TestedApp.Count property specifies. If Count is 0, no instances will be run.

Note: The number of instances to be launched depends on the IgnoreRunning parameter. If this parameter is True, the Run method launches as many application instances as the Count parameter specifies.

If the IgnoreRunning parameter is False (default), the total number of running instances cannot exceed the value specified by the Count parameter. Suppose, the Count parameter holds seven meaning that TestComplete can run a maximum of seven instances of your tested application. Suppose also, that five instances are already running. In this case, TestComplete will only run two new instances of the tested application (2 + 5 = 7).

The Count parameter is ignored if the Debug or Profile run mode is selected. If Profile mode is selected, TestComplete launches the application under AQtime, so the Count value is meaningless. If Debug mode is active, TestComplete always launches one application instance.

 

Про демо не упомянуто.

Думаю, что у вас "If Debug mode is active, TestComplete always launches one application instance".

Режимы описаны тут:

http://support.smartbear.com/viewarticle/28782/

 

Debug Mode

When Debug run mode is selected, TestComplete acts as a debugger for the tested application. After it launches the application, it monitors events that occur during the application run and reports information on these events to the test log. The traced events include debug strings sent by the application to the debugger, exceptions, the load and unload of modules and many others (see List of Traced Events).

For each event, TestComplete posts a message with appropriate information to the test log. For instance, if an exception occurs in the application under test, TestComplete posts the exception information to the log along with the stack of function calls that led to the exception (the exception information is added as an error message to the Test log table and the call stack is visible in the Remarks pane when you select this error message).

The Debug run mode is only available if the DbgServices plug-in is installed in TestComplete.

The tracing functionality is controlled by two options located in the DbgServices Options dialog: Enable events and Priority. The Enable events setting turns event tracking on or off. Priority sets the priority attached to the messages posted to the test log of each application event. You can choose a priority level that will distinguish event messages from other messages.

You can also control the DbgServices options from tests through the DbgServices.Options property.

To enable exception tracing, activate the Exceptions | Active option.

In order for TestComplete to be able to include function names and source line numbers in the call stack, the application under test must be compiled with debug information.

Also, note that when using the Debug mode, TestComplete ignores the Count value specified for the tested application (this value specifies the number of application instances TestComplete should run). If the Debug mode is selected, TestComplete always launches one new application instance.

To use the Debug run mode for your tested application, specify Debug in the Run Mode column of the TestedApps editor.

The Debug mode has two parameters that let you specify command-line arguments and a working folder for the application. To configure these parameters, select the Debug run mode in the TestedApps editor, press the ellipsis button in the Parameters cell and use edit boxes of the ensuing Parameters dialog.

You can also activate the Debug mode and specify its parameters from scripts or keyword tests. For more information on this, see Modifying Run-Mode Parameters From Scripts.

For complete information on using the Debug mode, see Tracing Events and Exceptions With Debug Services.

успешный запрос: http://goo.gl/oYLJr

 


(FreeMan) #5

 

Спасибо, вот так заработало.

Function getRandomNumber
  getRandomNumber = Round(rnd() * 500)
End Function
Sub Test1
  Dim p8
  Dim wndp89c000000
  Dim p89c000000
  Dim wndAccruals
  Dim wndp89c0000002
  TestedApps.p8.Run
  Set p8 = Aliases.p8
  Call p8.wndLogin.Keys("з[BS]~![ReleaseLast][ReleaseLast]login[Tab]password[Enter]")
  Set wndp89c000000 = p8.wndp89c000000
  Delay (5000)
  Call wndp89c000000.MainMenu.Click("System|[1]|[0]")
  Set p89c000000 = wndp89c000000.p89c000000
  Set wndAccruals = p89c000000.wndAccruals
  Call wndAccruals.Click(27, 47)
  Set wndp89c0000002 = p89c000000.wndp89c000000 

Randomize

  Call wndp89c0000002.Keys(getRandomNumber)
  Call wndp89c0000002.Click(162, 377)
  Call wndp89c0000002.Keys("123")
  Call wndp89c0000002.Click(302, 385)
  Call wndp89c0000002.Keys("123")
  Call wndp89c0000002.Click(320, 421)
  Call wndAccruals.Click(400, 419)
  Call wndp89c000000.MainMenu.Click("File|[1]")
End Sub