Skip to content

Commit a7d7311

Browse files
committed
add some tests
1 parent 736fa9a commit a7d7311

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium.htmlunit;
19+
20+
import org.junit.Test;
21+
import org.junit.runner.RunWith;
22+
import org.openqa.selenium.By;
23+
import org.openqa.selenium.WebDriver;
24+
import org.openqa.selenium.WebElement;
25+
import org.openqa.selenium.htmlunit.junit.BrowserRunner;
26+
import org.openqa.selenium.htmlunit.junit.BrowserRunner.Alerts;
27+
28+
/**
29+
* Separate test class for the HtmlUnitWebElement.getCssValue(String) method.
30+
*
31+
* @author Ronald Brill
32+
*/
33+
@RunWith(BrowserRunner.class)
34+
public class HtmlUnitWebElementCssTest extends WebDriverTestCase {
35+
36+
/**
37+
* @throws Exception if the test fails
38+
*/
39+
@Test
40+
@Alerts("block")
41+
public void defaultStyle() throws Exception {
42+
final String html =
43+
"<html>\n"
44+
+ "<head></head>\n"
45+
+ "<body>\n"
46+
+ " <div id='tester'>HtmlUnit</div>\n"
47+
+ "</form>\n"
48+
+ "</body></html>";
49+
50+
final WebDriver driver = loadPage2(html);
51+
final WebElement element = driver.findElement(By.id("tester"));
52+
assertNotNull(element);
53+
54+
assertEquals(getExpectedAlerts()[0], element.getCssValue("display"));
55+
}
56+
57+
/**
58+
* @throws Exception if the test fails
59+
*/
60+
@Test
61+
@Alerts("none")
62+
public void styleAttribute() throws Exception {
63+
final String html =
64+
"<html>\n"
65+
+ "<head></head>\n"
66+
+ "<body>\n"
67+
+ " <div id='tester' style='display: none'>HtmlUnit</div>\n"
68+
+ "</form>\n"
69+
+ "</body></html>";
70+
71+
final WebDriver driver = loadPage2(html);
72+
final WebElement element = driver.findElement(By.id("tester"));
73+
assertNotNull(element);
74+
75+
assertEquals(getExpectedAlerts()[0], element.getCssValue("display"));
76+
}
77+
78+
/**
79+
* @throws Exception if the test fails
80+
*/
81+
@Test
82+
@Alerts("inline")
83+
public void css() throws Exception {
84+
final String html =
85+
"<html>\n"
86+
+ "<head>\n"
87+
+ "<style>\n"
88+
+ " div { display: inline}\n"
89+
+ "</style>\n"
90+
+ "</head>\n"
91+
+ "<body>\n"
92+
+ " <div id='tester'>HtmlUnit</div>\n"
93+
+ "</form>\n"
94+
+ "</body></html>";
95+
96+
final WebDriver driver = loadPage2(html);
97+
final WebElement element = driver.findElement(By.id("tester"));
98+
assertNotNull(element);
99+
100+
assertEquals(getExpectedAlerts()[0], element.getCssValue("display"));
101+
}
102+
}

0 commit comments

Comments
 (0)