Skip to content

Commit f2bb467

Browse files
committed
test(selector.2ndgen): add test for :checked when the selected option changes
see #94
1 parent 345fc56 commit f2bb467

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<!--
3+
~ Copyright (c) 2016 seleniumQuery authors
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<!--suppress HtmlFormInputWithoutLabel -->
19+
<html>
20+
<head>
21+
<meta charset="utf-8">
22+
<title>seleniumQuery :checked with changes test page</title>
23+
</head>
24+
<body>
25+
<select>
26+
<option>AAA</option>
27+
<option id="b" selected>BBB</option>
28+
<option id="c">CCC</option>
29+
</select>
30+
</body>
31+
</html>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2016 seleniumQuery authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package endtoend.selectors.pseudoclasses.form;
18+
19+
import org.junit.ClassRule;
20+
import org.junit.Rule;
21+
import org.junit.Test;
22+
import testinfrastructure.SecondGenSelectorSystemDetector;
23+
import testinfrastructure.junitrule.SetUpAndTearDownDriver;
24+
25+
import static io.github.seleniumquery.SeleniumQuery.$;
26+
import static org.hamcrest.Matchers.is;
27+
import static org.junit.Assert.assertThat;
28+
29+
public class CheckedPseudoClassWithChangeTest {
30+
31+
@ClassRule @Rule public static SetUpAndTearDownDriver setUpAndTearDownDriverRule = new SetUpAndTearDownDriver();
32+
33+
@Test
34+
public void checkedPseudoClass__when_selected_changes() {
35+
SecondGenSelectorSystemDetector.assumeSecondGenSelectorSystem();
36+
assertThat($(":checked").size(), is(1));
37+
assertThat($(":checked").attr("id"), is("b"));
38+
39+
assertThat($("[selected]").size(), is(1));
40+
assertThat($("[selected]").attr("id"), is("b"));
41+
42+
$("#c").prop("selected", true);
43+
44+
assertThat($(":checked").size(), is(1));
45+
assertThat($(":checked").attr("id"), is("c"));
46+
47+
assertThat($("[selected]").size(), is(1));
48+
assertThat($("[selected]").attr("id"), is("b"));
49+
}
50+
51+
}

0 commit comments

Comments
 (0)