-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathProgram.cs
More file actions
106 lines (90 loc) · 2.94 KB
/
Program.cs
File metadata and controls
106 lines (90 loc) · 2.94 KB
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
//******************************************************************************
//
// Copyright (c) 2019 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium;
namespace UIXPathLib
{
public class DesktopSession
{
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723/";
WindowsDriver<WindowsElement> desktopSession;
public DesktopSession()
{
AppiumOptions appOptions = new AppiumOptions();
appOptions.AddAdditionalCapability("app", "Root");
appOptions.AddAdditionalCapability("deviceName", "WindowsPC");
desktopSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appOptions);
}
~DesktopSession()
{
desktopSession.Quit();
}
public WindowsDriver<WindowsElement> DesktopSessionElement
{
get { return desktopSession; }
}
public WindowsElement FindElementByAbsoluteXPath(string xPath, int nTryCount = 10)
{
WindowsElement uiTarget = null;
while (nTryCount-- > 0)
{
try
{
uiTarget = desktopSession.FindElementByXPath(xPath);
}
catch
{
}
if (uiTarget != null)
{
break;
}
else
{
System.Threading.Thread.Sleep(2000);
}
}
return uiTarget;
}
}
class Program
{
static void Main(string[] args)
{
DesktopSession desktopSession = new DesktopSession();
System.Threading.Thread.Sleep(2000);
bool bSuccess = false;
try
{
//Paste generated code here
//test complete
bSuccess = true;
}
finally
{
Assert.AreEqual(bSuccess, true);
}
}
}
}