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 @@ -167,6 +167,9 @@ public Filtered(
parametersTracker.setMethodParameters(locatorParameters);
parametersTracker.setMethodParameters(applyParameters);
parametersTracker.setMethodParameters(matcherParameters);
parametersTracker
.getMethodParameters()
.forEach(param -> ParameterUtils.setImport(classImports, param.getType()));
String locationCode = getElementLocationCode(componentName, locatorParameters);
String predicate =
getPredicateCode(applyMethod, applyParameters, matcherType, matcherParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,26 @@ public void testFilterWithContainsElementSelectorArgument() {
expected.addImpliedImportedTypes("utam.core.selenium.element.LocatorBy");
PageObjectValidationTestHelper.validateMethod(method, expected);
}

@Test
public void testFilterCustomElementWithContainsElementSelectorArgument() {
TranslationContext context =
new DeserializerUtilities().getContext("filter/customWithFilterContainsElement");
PageObjectMethod method = context.getMethod(ELEMENT_METHOD_NAME);
assertThat(method.getDeclaration().getCodeLine(), is(equalTo("Custom getTest(String value)")));
MethodInfo expected = new MethodInfo(ELEMENT_METHOD_NAME, "Custom");
expected.addParameter(new MethodParameterInfo("value", "String"));
expected.addParameter(
new MethodParameterInfo(
"LocatorBy.byCss(String.format(\"input[value='%s']\", value))", "LocatorBy"));
expected.addCodeLine("BasicElement root = this.getRootElement()");
expected.addCodeLine(
"return custom(root, this.test).build(Custom.class, elm ->"
+ " Boolean.TRUE.equals(elm.containsElement(LocatorBy.byCss(String.format(\"input[value='%s']\","
+ " value)))))");
expected.addImpliedImportedTypes("utam.custom.pageobjects.Custom");
expected.addImpliedImportedTypes("utam.core.element.BasicElement");
expected.addImpliedImportedTypes("utam.core.selenium.element.LocatorBy");
PageObjectValidationTestHelper.validateMethod(method, expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"elements": [
{
"name": "test",
"public": true,
"type": "utam-custom/pageObjects/custom",
"selector": {
"css": "my-custom-element[with-attribute='attr-value']",
"returnAll": true
},
"filter": {
"apply": "containsElement",
"args": [
{
"type": "locator",
"value": {
"css": "input[value='%s']",
"args": [
{
"name": "value",
"type": "string"
}
]
}
}
],
"findFirst": true,
"matcher": {
"type": "isTrue"
}
}
}
]
}
Loading