forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestMultiSelect.cs
53 lines (52 loc) · 2.3 KB
/
TestMultiSelect.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
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
namespace Selenium.Tests
{
[TestFixture]
public class TestMultiSelect : SeleniumTestCaseBase
{
[Test]
public void ShouldBeAbleToMultiSelect()
{
selenium.Open("../tests/html/test_multiselect.html");
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "Second Option");
selenium.Select("theSelect", "index=4");
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "Fifth Option");
selenium.AddSelection("theSelect", "Third Option");
selenium.AddSelection("theSelect", "value=");
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "Third Option,Fifth Option,Empty Value Option");
selenium.RemoveSelection("theSelect", "id=o7");
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "Third Option,Fifth Option");
selenium.RemoveSelection("theSelect", "label=Fifth Option");
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "Third Option"); ;
selenium.AddSelection("theSelect", "");
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "Third Option,");
selenium.RemoveSelection("theSelect", "");
selenium.RemoveSelection("theSelect", "Third Option");
try
{
Assert.AreEqual(selenium.GetSelectedLabel("theSelect"), "");
Assert.Fail("expected failure");
}
catch (Exception)
{
}
try
{
Assert.AreEqual(string.Join(",", selenium.GetSelectedLabels("theSelect")), "");
Assert.Fail("expected failure");
}
catch (Exception)
{
}
Assert.AreEqual(selenium.GetValue("theSelect"), "");
Assert.IsFalse(selenium.IsSomethingSelected("theSelect"));
selenium.AddSelection("theSelect", "Third Option");
selenium.AddSelection("theSelect", "value=");
selenium.RemoveAllSelections("theSelect");
Assert.IsFalse(selenium.IsSomethingSelected("theSelect"));
}
}
}