-
Notifications
You must be signed in to change notification settings - Fork 188
/
Copy pathClickElementTest.cs
134 lines (121 loc) · 5.74 KB
/
ClickElementTest.cs
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//See the NOTICE file distributed with this work for additional
//information regarding copyright ownership.
//You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
using Appium.Net.Integration.Tests.helpers;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
namespace Appium.Net.Integration.Tests.Windows
{
public class ClickElementTest
{
private WindowsDriver _calculatorSession;
protected static WebElement CalculatorResult;
private readonly string _appId = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App";
[OneTimeSetUp]
public void BeforeAll()
{
var appCapabilities = new AppiumOptions
{
AutomationName = "Windows",
App = _appId,
DeviceName = "WindowsPC",
PlatformName = "Windows"
};
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_calculatorSession = new WindowsDriver(serverUri, appCapabilities,
Env.InitTimeoutSec);
_calculatorSession.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
_calculatorSession.FindElement(MobileBy.Name("Clear")).Click();
_calculatorSession.FindElement(MobileBy.Name("Seven")).Click();
CalculatorResult = _calculatorSession.FindElement(MobileBy.Name("Display is 7"));
Assert.That(CalculatorResult, Is.Not.Null);
}
[OneTimeTearDown]
public void OneTimeTearDown()
{
CalculatorResult = null;
_calculatorSession?.CloseApp();
_calculatorSession?.Dispose();
_calculatorSession = null;
}
[SetUp]
public void SetUp()
{
_calculatorSession.FindElement(MobileBy.Name("Clear")).Click();
Assert.That(CalculatorResult.Text, Is.EqualTo("Display is 0"));
}
[Test]
public void Addition()
{
_calculatorSession.FindElement(MobileBy.Name("One")).Click();
_calculatorSession.FindElement(MobileBy.Name("Plus")).Click();
_calculatorSession.FindElement(MobileBy.Name("Seven")).Click();
_calculatorSession.FindElement(MobileBy.Name("Equals")).Click();
Assert.That(CalculatorResult.Text, Is.EqualTo("Display is 8"));
}
[Test]
public void AdditionWithCompoundBys()
{
_calculatorSession.FindElement(MobileBy.ClassName("ApplicationFrameWindow")).FindElement(MobileBy.Name("One")).Click();
_calculatorSession.FindElement(MobileBy.AccessibilityId("plusButton")).Click();
_calculatorSession.FindElement(MobileBy.Name("Calculator")).FindElement(MobileBy.Name("Five")).Click();
_calculatorSession.FindElement(MobileBy.Name("Equals")).Click();
Assert.That(CalculatorResult.Text, Is.EqualTo("Display is 6"));
}
[Test]
public void Combination()
{
_calculatorSession.FindElement(MobileBy.Name("Seven")).Click();
_calculatorSession.FindElement(MobileBy.Name("Multiply by")).Click();
_calculatorSession.FindElement(MobileBy.Name("Nine")).Click();
_calculatorSession.FindElement(MobileBy.Name("Plus")).Click();
_calculatorSession.FindElement(MobileBy.Name("One")).Click();
_calculatorSession.FindElement(MobileBy.Name("Equals")).Click();
_calculatorSession.FindElement(MobileBy.Name("Divide by")).Click();
_calculatorSession.FindElement(MobileBy.Name("Eight")).Click();
_calculatorSession.FindElement(MobileBy.Name("Equals")).Click();
Assert.That(CalculatorResult.Text, Is.EqualTo("Display is 8"));
}
[Test]
public void Division()
{
_calculatorSession.FindElement(MobileBy.Name("Eight")).Click();
_calculatorSession.FindElement(MobileBy.Name("Eight")).Click();
_calculatorSession.FindElement(MobileBy.Name("Divide by")).Click();
_calculatorSession.FindElement(MobileBy.Name("One")).Click();
_calculatorSession.FindElement(MobileBy.Name("One")).Click();
_calculatorSession.FindElement(MobileBy.Name("Equals")).Click();
Assert.That(CalculatorResult.Text, Is.EqualTo("Display is 8"));
}
[Test]
public void Multiplication()
{
_calculatorSession.FindElement(MobileBy.Name("Nine")).Click();
_calculatorSession.FindElement(MobileBy.Name("Multiply by")).Click();
_calculatorSession.FindElement(MobileBy.Name("Nine")).Click();
_calculatorSession.FindElement(MobileBy.Name("Equals")).Click();
Assert.That(CalculatorResult.Text, Is.EqualTo("Display is 81"));
}
[Test]
public void Subtraction()
{
_calculatorSession.FindElement(MobileBy.Name("Nine")).Click();
_calculatorSession.FindElement(MobileBy.Name("Minus")).Click();
_calculatorSession.FindElement(MobileBy.Name("One")).Click();
_calculatorSession.FindElement(MobileBy.Name("Equals")).Click();
Assert.That(CalculatorResult.Text, Is.EqualTo("Display is 8"));
}
}
}