forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestVerifications.cs
44 lines (43 loc) · 2.44 KB
/
TestVerifications.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
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Text.RegularExpressions;
namespace Selenium.Tests
{
[TestFixture]
public class TestVerifications : SeleniumTestCaseBase
{
[Test]
public void ShouldBeAbleToVerify()
{
selenium.Open("../tests/html/test_verifications.html?foo=bar");
Assert.IsTrue(Regex.IsMatch(selenium.GetLocation(), "^[\\s\\S]*/tests/html/test_verifications\\.html[\\s\\S]*$"));
Assert.IsTrue(Regex.IsMatch(selenium.GetLocation(), "^[\\s\\S]*/tests/html/test_verifications\\.html[\\s\\S]foo=bar$"));
Assert.AreEqual(selenium.GetValue("theText"), "the text value");
Assert.AreNotEqual("not the text value", selenium.GetValue("theText"));
Assert.AreEqual(selenium.GetValue("theHidden"), "the hidden value");
Assert.AreEqual(selenium.GetText("theSpan"), "this is the span");
Assert.AreNotEqual("blah blah", selenium.GetText("theSpan"));
Assert.IsTrue(selenium.IsTextPresent("this is the span"));
Assert.IsFalse(selenium.IsTextPresent("this is not the span"));
Assert.IsTrue(selenium.IsElementPresent("theSpan"));
Assert.IsTrue(selenium.IsElementPresent("theText"));
Assert.IsFalse(selenium.IsElementPresent("unknown"));
Assert.AreEqual(selenium.GetTable("theTable.0.0"), "th1");
Assert.AreEqual(selenium.GetTable("theTable.1.0"), "a");
Assert.AreEqual(selenium.GetTable("theTable.2.1"), "d");
Assert.AreEqual(selenium.GetTable("theTable.3.1"), "f2");
Assert.AreEqual(selenium.GetSelectedIndex("theSelect"), "1"); ;
Assert.AreEqual(selenium.GetSelectedValue("theSelect"), "option2"); ;
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "second option"); ;
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "second option"); ;
Assert.AreEqual(selenium.GetSelectedId("theSelect"), "o2"); ;
Assert.AreEqual(string.Join(",", selenium.GetSelectOptions("theSelect")), "first option,second option,third,,option");
Assert.AreEqual(selenium.GetAttribute("theText@class"), "foo");
Assert.AreNotEqual("fox", selenium.GetAttribute("theText@class"));
Assert.AreEqual(selenium.GetTitle(), "theTitle");
Assert.AreNotEqual("Blah Blah", selenium.GetTitle());
}
}
}