Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<title>Issue4331IT - adding new keyword resolver via faces-config.xml</title>
</h:head>
<h:body>
<h:inputText id="input">
<h:inputText id="issue4331ITInput1">
<f:ajax render="@custom" />
</h:inputText>
</h:body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ void test() throws Exception {
public void testCustomSearchKeywordResolverAddedViaFacesConfig() throws Exception {
WebPage page = getPage("issue4331.xhtml");

WebElement input = getWebDriver().findElement(By.id("input"));
assertFalse(input.getDomAttribute("onchange").contains("@custom"));
assertTrue(input.getDomAttribute("onchange").contains("input"));
WebElement input = getWebDriver().findElement(By.id("issue4331ITInput1"));

String behaviorScript = getBehaviorScript(page, input);

assertFalse(behaviorScript.contains("@custom"));
assertTrue(behaviorScript.contains("issue4331ITInput1"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.Duration;
Expand Down Expand Up @@ -51,17 +50,16 @@ public void testSearchExpression() throws Exception {
ExtendedWebDriver webDriver = getWebDriver();
WebElement label = webDriver.findElement(By.id("label"));
WebElement input = webDriver.findElement(By.id("spec1238ITinput1"));

assertEquals(label.getDomAttribute("for"), input.getDomAttribute("id"));

String onchange = input.getDomAttribute("onchange");

if (onchange.contains("@this")) {
assertFalse(onchange.contains("spec1238ITinput1"));
String behaviorScript = getBehaviorScript(page, input);

if (behaviorScript.contains("@this")) {
assertTrue(behaviorScript.contains("@this spec1238ITinput2"));
}
else {
assertTrue(onchange.contains("spec1238ITinput1"));
assertTrue(behaviorScript.contains("spec1238ITinput1 spec1238ITinput2"));
}
assertTrue(onchange.contains("spec1238ITinput2"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -79,23 +80,23 @@ void clinkRenderEncodeTest() throws Exception {
WebElement link1 = page.findElement(By.id("form:link1"));
assertEquals("#",link1.getDomAttribute​("href"));
assertEquals("Click Me1",link1.getText());
assertFalse(link1.getDomAttribute​("onclick").length() < 0);
assertNotNull(getBehaviorScript(page, link1));

WebElement link2 = page.findElement(By.id("form:link2"));
assertEquals("#",link1.getDomAttribute​("href"));
assertEquals("Click Me2",link2.getText());
assertEquals("sansserif", link2.getDomAttribute​("class"));
assertFalse(link2.getDomAttribute​("onclick").length() < 0);
assertNotNull(getBehaviorScript(page, link2));

WebElement link3 = page.findElement(By.id("form:link3"));
assertEquals("#",link3.getDomAttribute​("href"));
assertEquals("Click Me3",link3.getText());
assertFalse(link3.getDomAttribute​("onclick").length() < 0);
assertNotNull(getBehaviorScript(page, link3));

WebElement link5 = page.findElement(By.id("form:link5"));
assertEquals("sansserif", link5.getDomAttribute​("class"));
assertEquals("Disabled Link",link5.getText());
assertNull(link5.getDomAttribute​("onclick"));
assertNull(getBehaviorScript(page, link5));

WebElement span2 = page.findElement(By.id("form:link6"));
assertEquals("Disabled Link(Nested)",span2.getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
*/
package ee.jakarta.tck.faces.test.util.selenium;

import static java.lang.Boolean.parseBoolean;
import static java.lang.System.getProperty;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;

import java.io.File;
import java.net.URL;
import java.time.Duration;
Expand All @@ -34,15 +40,10 @@
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;

import static java.lang.Boolean.parseBoolean;
import static java.lang.System.getProperty;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;

/**
* Use this for Selenium based tests.
*/
Expand Down Expand Up @@ -126,4 +127,21 @@ protected String getHrefURI(WebElement link) {

return uriWithoutJsessionId;
}

protected String getBehaviorScript(WebPage page, WebElement input) {
var id = input.getAttribute("id");

for (var script : page.findElements(By.tagName("script"))) {
var src = script.getAttribute("src");
if (src == null || src.isEmpty()) {
var content = script.getDomProperty("textContent");

if (content.contains("'" + id + "'") || content.contains("\"" + id + "\"")) {
return content;
}
}
}

return null;
}
}