-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumatorAppPOMTests.cs
More file actions
88 lines (76 loc) · 2.64 KB
/
Copy pathSumatorAppPOMTests.cs
File metadata and controls
88 lines (76 loc) · 2.64 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
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Service;
using OpenQA.Selenium.Appium;
namespace Appium_Testing
{
public class SumatorAppPOMTests
{
private AndroidDriver driver;
private AppiumLocalService service;
private SumatorPage sumatorPage;
[OneTimeSetUp]
public void Setup()
{
service = new AppiumServiceBuilder()
.WithIPAddress("127.0.0.1")
.UsingPort(4723)
.Build();
service.Start();
AppiumOptions options = new AppiumOptions();
options.App = @"C:\Users\Stef\Desktop\com.example.androidappsummator.apk";
options.PlatformName = "Android";
options.AutomationName = "UiAutomator2";
options.DeviceName = "Pixel_7_API_34";
options.PlatformVersion = "14.0";
driver = new AndroidDriver(service, options);
sumatorPage = new SumatorPage(driver);
}
[OneTimeTearDown]
public void TearDown()
{
driver?.Quit();
service?.Dispose();
}
[Test]
public void TestValidSumator()
{
var result = sumatorPage.GetResult("2", "5");
Assert.That(result, Is.EqualTo("7"));
}
[Test]
public void TestInvalidSumator_ClickOnlySumButton()
{
sumatorPage.ClearFields();
sumatorPage.sumButton.Click();
Assert.That(sumatorPage.resultField.Text, Is.EqualTo("error"));
}
[Test]
public void TestInvalidSumator_FillOnlyFirstField()
{
sumatorPage.ClearFields();
sumatorPage.firstField.SendKeys("2");
sumatorPage.sumButton.Click();
Assert.That(sumatorPage.resultField.Text, Is.EqualTo("error"));
}
[Test]
public void TestInvalidSumator_FillOnlySecondField()
{
sumatorPage.ClearFields();
sumatorPage.secondField.SendKeys("2");
sumatorPage.sumButton.Click();
Assert.That(sumatorPage.resultField.Text, Is.EqualTo("error"));
}
[Test]
[TestCase("10", "10", "20")]
[TestCase("0", "0", "0")]
[TestCase("100", "100", "200")]
[TestCase("1000", "1000", "2000")]
[TestCase("0", "1000", "1000")]
[TestCase("10.9", "10.1", "21.0")]
public void TestWithValidData_Parametrized(string input1, string input2, string expectedResults)
{
var result = sumatorPage.GetResult(input1, input2);
Assert.That(result, Is.EqualTo(expectedResults));
}
}
}