forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestWaitForNot.cs
59 lines (56 loc) · 1.8 KB
/
TestWaitForNot.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
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Text.RegularExpressions;
using System.Threading;
namespace Selenium.Tests
{
[TestFixture]
public class TestWaitForNot : SeleniumTestCaseBase
{
[Test]
public void ShouldBeAbleToWaitForNot()
{
selenium.Open("../tests/html/test_async_event.html");
Assert.AreEqual(selenium.GetValue("theField"), "oldValue");
selenium.Click("theButton");
Assert.AreEqual(selenium.GetValue("theField"), "oldValue");
for (int second = 0; ; second++)
{
if (second >= 60) Assert.Fail("timeout");
try
{
if (!Regex.IsMatch(selenium.GetValue("theField"), "oldValu[aei]"))
{
break;
}
}
catch (Exception)
{
}
Thread.Sleep(1000);
}
Assert.AreEqual(selenium.GetValue("theField"), "newValue");
Assert.AreEqual(selenium.GetText("theSpan"), "Some text");
selenium.Click("theSpanButton");
Assert.AreEqual(selenium.GetText("theSpan"), "Some text");
for (int second = 0; ; second++)
{
if (second >= 60) Assert.Fail("timeout");
try
{
if (!Regex.IsMatch(selenium.GetText("theSpan"), "Some te[xyz]t"))
{
break;
}
}
catch (Exception)
{
}
Thread.Sleep(1000);
}
Assert.AreEqual(selenium.GetText("theSpan"), "Some new text");
}
}
}