FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UIAVerify/SampleDriver/Program.cs at master · TestStack/UIAVerify · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
TestStack
/
UIAVerify
Public
Notifications
You must be signed in to change notification settings
Fork
18
Star
28
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
UIAVerify
/
SampleDriver
/
Program.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
107 lines (86 loc) · 3.83 KB
Breadcrumbs
UIAVerify
/
SampleDriver
/
Program.cs
Copy path
File metadata and controls
107 lines (86 loc) · 3.83 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//---------------------------------------------------------------------------
//
// <copyright file="Program.cs" company="Microsoft">
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
// All other rights reserved.
// </copyright>
//
//
//---------------------------------------------------------------------------
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Text
;
using
System
.
Diagnostics
;
using
System
.
Threading
;
using
System
.
Windows
.
Automation
;
using
Microsoft
.
Test
.
UIAutomation
;
using
Microsoft
.
Test
.
UIAutomation
.
Core
;
using
Microsoft
.
Test
.
UIAutomation
.
TestManager
;
using
Microsoft
.
Test
.
UIAutomation
.
Tests
.
Controls
;
using
Microsoft
.
Test
.
UIAutomation
.
Tests
.
Patterns
;
using
Microsoft
.
Test
.
UIAutomation
.
Logging
;
namespace
SampleDriver
{
public
sealed
class
TestMain
{
/// -------------------------------------------------------------------
/// <summary>
/// This sample will start up Notepad and run UI Automation tests on it
/// </summary>
/// -------------------------------------------------------------------
[
STAThread
]
static
void
Main
(
string
[
]
args
)
{
// Dump the info to the console window. Use a different LogTypes if
// you need to dump to another logger, of create your own that complies
// to the interface.
UIVerifyLogger
.
SetLogger
(
LogTypes
.
ConsoleLogger
)
;
// Get the automation element you want to test
AutomationElement
element
=
StartApplication
(
"NOTEPAD.EXE"
,
null
)
;
// Call the UI Automation Verify tests
TestRuns
.
RunAllTests
(
element
,
true
,
TestPriorities
.
Pri0
,
TestCaseType
.
Generic
,
false
,
true
,
null
)
;
// Clean up
(
(
WindowPattern
)
element
.
GetCurrentPattern
(
WindowPattern
.
Pattern
)
)
.
Close
(
)
;
// Dumps the summary of results
UIVerifyLogger
.
ReportResults
(
)
;
}
/// -------------------------------------------------------------------------
/// <summary>
/// Start the application and retrieve it's AutomationElement
/// </summary>
/// -------------------------------------------------------------------------
static
public
AutomationElement
StartApplication
(
string
appPath
,
string
arguments
)
{
int
MAXTIME
=
5000
;
// Total length in milliseconds to wait for the application to start
int
TIMEWAIT
=
100
;
// Timespan to wait till trying to find the window
Process
process
;
Library
.
ValidateArgumentNonNull
(
appPath
,
"appPath"
)
;
ProcessStartInfo
psi
=
new
ProcessStartInfo
(
)
;
process
=
new
Process
(
)
;
psi
.
FileName
=
appPath
;
if
(
arguments
!=
null
)
{
psi
.
Arguments
=
arguments
;
}
UIVerifyLogger
.
LogComment
(
"Starting({0})"
,
appPath
)
;
process
.
StartInfo
=
psi
;
process
.
Start
(
)
;
// this is for piper, but is a nop for others such as wtt
UIVerifyLogger
.
MonitorProcess
(
process
)
;
int
runningTime
=
0
;
while
(
process
.
MainWindowHandle
.
Equals
(
IntPtr
.
Zero
)
)
{
if
(
runningTime
>
MAXTIME
)
throw
new
Exception
(
"Could not find "
+
appPath
)
;
Thread
.
Sleep
(
TIMEWAIT
)
;
runningTime
+=
TIMEWAIT
;
process
.
Refresh
(
)
;
}
UIVerifyLogger
.
LogComment
(
"{0} started"
,
appPath
)
;
UIVerifyLogger
.
LogComment
(
"Obtained an AutomationElement for {0}"
,
appPath
)
;
return
AutomationElement
.
FromHandle
(
process
.
MainWindowHandle
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL