/
ElementStateTests.cs
92 lines (82 loc) · 4.22 KB
/
ElementStateTests.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
using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms;
using NUnit.Framework;
using OpenQA.Selenium;
namespace Aquality.Selenium.Tests.Integration
{
internal class ElementStateTests : UITest
{
private readonly DynamicControlsForm dynamicControlsForm = new();
[SetUp]
public void BeforeTest()
{
dynamicControlsForm.Open();
}
[Test]
public void Should_BePossibleTo_CheckEnabledElementState()
{
Assert.Multiple(() =>
{
Assert.That(dynamicControlsForm.ChangeInputStateButton.State.IsEnabled, "Change state button should be enabled");
Assert.That(dynamicControlsForm.TextInputTextBox.State.IsEnabled, Is.False, "Text input should be disabled");
});
}
[Test]
public void Should_BePossibleTo_CheckDisplayedElementState()
{
Assert.Multiple(() =>
{
Assert.That(dynamicControlsForm.TextInputTextBox.State.IsDisplayed, "Text input should be displayed");
Assert.That(dynamicControlsForm.LoadingLabel.State.IsDisplayed, Is.False, "Loading should not be displayed");
});
}
[Test]
public void Should_BePossibleTo_CheckExistElementState()
{
Assert.That(dynamicControlsForm.LoadingLabel.State.IsExist, Is.False, "Loading element should not be exist by default");
dynamicControlsForm.ChangeInputStateButton.Click();
Assert.That(dynamicControlsForm.LoadingLabel.State.IsExist, "Loading element should not exist after changing state");
}
[Test]
public void Should_BePossibleTo_CheckElementIsClickableState()
{
Assert.Multiple(() =>
{
Assert.That(dynamicControlsForm.ChangeInputStateButton.State.IsClickable, "Change state button should be clickable");
Assert.That(dynamicControlsForm.TextInputTextBox.State.IsClickable, Is.False, "Text input should not be clickable");
});
}
[Test]
public void Should_BePossibleTo_WaitForElementEnabledState()
{
Assert.That(dynamicControlsForm.State.WaitForDisplayed(), "Form 'Dynamic Controls' should be displayed");
dynamicControlsForm.ChangeInputStateButton.Click();
Assert.That(dynamicControlsForm.TextInputTextBox.State.WaitForEnabled(), "Text input should be enable after changing state");
dynamicControlsForm.ChangeInputStateButton.Click();
Assert.That(dynamicControlsForm.TextInputTextBox.State.WaitForNotEnabled(), "Text input should be disabled after changing state");
}
[Test]
public void Should_BePossibleTo_WaitForElementDisplayedState()
{
dynamicControlsForm.RemoveAddExampleButton.Click();
Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForNotDisplayed(), "Checkbox example should not be displayed after removing");
dynamicControlsForm.RemoveAddExampleButton.Click();
Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForDisplayed(), "Checkbox example should be displayed after adding");
}
[Test]
public void Should_BePossibleTo_WaitForElementExistState()
{
dynamicControlsForm.RemoveAddExampleButton.Click();
Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForNotExist(), "Checkbox example should not be exist after removing");
dynamicControlsForm.RemoveAddExampleButton.Click();
Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForExist(), "Checkbox example should be exist after adding");
}
[Test]
public void Should_BePossibleTo_WaitForElementIsClickable()
{
Assert.Throws<WebDriverTimeoutException>(() => dynamicControlsForm.TextInputTextBox.State.WaitForClickable(), "Textbox should not be clickable");
dynamicControlsForm.ChangeInputStateButton.Click();
dynamicControlsForm.TextInputTextBox.State.WaitForClickable();
Assert.That(dynamicControlsForm.TextInputTextBox.State.IsClickable, "Textbox should not be clickable after changing state");
}
}
}