Skip to content

Commit d2f1305

Browse files
authored
Merge pull request #5104 from jdi-testing/5094-pseudo-example
Add example for pseudo content (::before and ::after)
2 parents dbdd3f9 + f64a71f commit d2f1305

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

jdi-light-core/src/main/java/com/epam/jdi/light/elements/base/Conditions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ public static Condition matchValue(String value) {
6969
}
7070

7171
public static Condition pseudo(String pseudoName, String propertyName, String expectedValue) {
72-
return el -> el.pseudo(pseudoName, propertyName).equals(expectedValue);
72+
return condition("%element% has no pseudo " + pseudoName + " property " + propertyName + " with value " + expectedValue,
73+
el -> el.pseudo(pseudoName, propertyName).equals(expectedValue));
7374
}
7475

7576
public static Condition pseudo(String pseudoElementName, String expectedValue) {
76-
return el -> el.pseudo(pseudoElementName, "content").equals(expectedValue);
77+
return pseudo(pseudoElementName, "content", expectedValue);
7778
}
7879

7980
public static Condition exactValue(String value) {

jdi-light-html-tests/src/main/java/io/github/com/pages/HtmlElementsPage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,7 @@ public class HtmlElementsPage extends WebPage {
155155
@UI("#shadowContainer")
156156
@ShadowHost
157157
public static ShadowElement shadowContainer;
158+
159+
@UI("#checkboxWithPseudo")
160+
public static Checkbox checkboxWithPseudo;
158161
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.epam.html.tests.elements.common;
2+
3+
import io.github.epam.TestsInit;
4+
import org.testng.annotations.BeforeMethod;
5+
import org.testng.annotations.Test;
6+
7+
import static com.epam.jdi.light.elements.base.Conditions.and;
8+
import static com.epam.jdi.light.elements.base.Conditions.pseudo;
9+
import static io.github.com.StaticSite.html5Page;
10+
import static io.github.com.pages.HtmlElementsPage.checkboxWithPseudo;
11+
import static io.github.epam.html.tests.site.steps.States.shouldBeLoggedIn;
12+
13+
public class PseudoTests implements TestsInit {
14+
@BeforeMethod
15+
public void before() {
16+
shouldBeLoggedIn();
17+
html5Page.open();
18+
}
19+
20+
@Test(description = "Check content in pseudo before and after")
21+
public void pseudoTest() {
22+
checkboxWithPseudo.show();
23+
24+
checkboxWithPseudo.shouldBe(
25+
pseudo("::before", "\"Before pseudo-element content\""),
26+
and(pseudo("::after", "\"After pseudo-element content\""))
27+
);
28+
}
29+
}

0 commit comments

Comments
 (0)