forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestSelect.cs
71 lines (70 loc) · 3.18 KB
/
TestSelect.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
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 TestSelect : SeleniumTestCaseBase
{
[Test]
public void ShouldBeAbleToSelect()
{
selenium.Open("../tests/html/test_select.html");
Assert.IsTrue(selenium.IsSomethingSelected("theSelect"));
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Second Option"); ;
selenium.Select("theSelect", "index=4");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Fifth Option");
Assert.AreEqual(selenium.GetSelectedIndex("theSelect"), "4");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Fifth Option");
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "Fifth Option");
selenium.Select("theSelect", "Third Option");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Third Option"); ;
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Third Option"); ;
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Third Option");
selenium.Select("theSelect", "label=Fourth Option");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Fourth Option");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Fourth Option"); ;
selenium.Select("theSelect", "value=option6");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Sixth Option");
Assert.AreEqual(selenium.GetSelectedValue("theSelect"), "option6");
Assert.AreEqual(selenium.GetSelectedValue("theSelect"), "option6"); ;
selenium.Select("theSelect", "value=");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Empty Value Option");
selenium.Select("theSelect", "id=o4");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Fourth Option");
Assert.AreEqual(selenium.GetSelectedId("theSelect"), "o4");
selenium.Select("theSelect", "");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "");
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "");
try
{
selenium.Select("theSelect", "Not an option");
Assert.Fail("expected failure");
}
catch (Exception)
{
}
try
{
selenium.AddSelection("theSelect", "Fourth Option");
Assert.Fail("expected failure");
}
catch (Exception)
{
}
try
{
selenium.RemoveSelection("theSelect", "Fourth Option");
Assert.Fail("expected failure");
}
catch (Exception)
{
}
Assert.AreEqual(string.Join(",", selenium.GetSelectOptions("theSelect")),
"First Option,Second Option,Third Option,Fourth Option,Fifth Option,Sixth Option,Empty Value Option,");
}
}
}