Monkeyrunner _ run monkeyrunner with qtp

Source: Internet
Author: User

I am too lazy to always enter commands in cmd. I found that qtp can be used to open cmd. Well, I can be too lazy to enter commands in cmd.

Run qtp in eclipseCode:

Import win32com, win32com. Client

I = 1
while (I <3):
qtp = win32com. client. dispatch ("quicktest. application ")
# Starts up qtp
qtp. launch ()
# Make the qtp window visible
qtp. visible = true
# open a test, replace the path
qtp. open ('e: \ hpqtpworkspace \ opencmd % d' % (I)
# To open a qtp test in Quality Center
# qtp. open (R "[qualitycenter] Subject \ Foldername \ qtpscript")
# create a runresultsoptions object
qtresultsopt = win32com. client. dispatch ("quicktest. runresultsoptions ")
# Set the location to where the results will be save
qtresultsopt. resultslocation = "E: \ hpqtpworkspace \ opencmd % d \ RES1" % (I)
qtp. test. run (qtresultsopt)
Print "test has % s" % qtp. test. lastrunresults. status
# Close the test
qtp. test. close ()
# Quit qtp
qtp. quit ()

So that I can run two monkeyrunner scripts.

Opencmd1 code:

Systemutil. Run "cmd.exe", "", "C: \ WINDOWS \ System32", "open"
'Close the Input Method
Window ("Object Class: = lelewindowclass"). Type micshiftdwn
Window ("Object Class: = lelewindowclass"). Type micshiftup

'Switch to the monkeyrunner directory.
Window ("Object Class: = lelewindowclass"). Type "E :"
Window ("Object Class: = lelewindowclass"). Type micreturn
Window ("Object Class: = lelewindowclass"). Type "cd e: \ Android \ androidsdkwindows \ tools"
Window ("Object Class: = lelewindowclass"). Type micreturn

'Get picture
Window ("Object Class: = lelewindowclass"). Type "monkeyrunner test \ capturescreen. py"

Window ("Object Class: = lelewindowclass"). Type micreturn

Wait (60)

Window ("Object Class: = lelewindowclass"). Type "exit ;"
Window ("Object Class: = lelewindowclass"). Type micreturn

Opencmd2 code:

Systemutil. Run "cmd.exe", "", "C: \ WINDOWS \ System32", "open"
'Close the Input Method
Window ("Object Class: = lelewindowclass"). Type micshiftdwn
Window ("Object Class: = lelewindowclass"). Type micshiftup

'Switch to the monkeyrunner directory.
Window ("Object Class: = lelewindowclass"). Type "E :"
Window ("Object Class: = lelewindowclass"). Type micreturn
Window ("Object Class: = lelewindowclass"). Type "cd e: \ Android \ androidsdkwindows \ tools \ test"
Window ("Object Class: = lelewindowclass"). Type micreturn

'Get picture
Window ("Object Class: = lelewindowclass"). Type "Python compareimage. py"

Window ("Object Class: = lelewindowclass"). Type micreturn

Wait (5)

Window ("Object Class: = lelewindowclass"). Type "exit ;"
Window ("Object Class: = lelewindowclass"). Type micreturn

 

It was done, but the implementation was not very good and it had to be improved.

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.