Closed nirsch closed 8 years ago
@nirsch Yes, that is weird. Will you please share the snippet of your PageYAML that reproduces this issue and the SeLion version you are using? FYI - here is an example source file with container markup - https://github.com/paypal/SeLion/blob/develop/client/src/test/resources/GUIData/paypal/TestPage.yml
@sebady fyi
I'm experiencing the issue in 1.0.0 and 1.1.0-SNAPSHOT. I start from the archetype and base the information below on version 1.1.0-SNAPSHOT. The custom element (called TestCustom) is designed as documented in the code gen documentation.
The PageYAML:
baseClass: "com.paypal.selion.testcomponents.BasicPageImpl"
pageTitle:
US: "about:blank"
elements:
anotherLabel:
locators:
US: "//div[1]"
testContainer:
locators:
US: "./html"
containerElements:
exampleTestCustom:
locators:
US: "./input"
testLabel:
locators:
US: "./a"
Snippet of SeLion generated code:
private Label anotherLabel;
private TestContainer testContainer;
private TestCustom exampleTestCustom;
public TestCustom getExampleTestCustom() {
TestCustom element = this.exampleTestCustom;
if(element == null) {
this.exampleTestCustom = new TestCustom(getObjectMap().get("exampleTestCustom"), "exampleTestCustom",
this);
}
return this.exampleTestCustom;
}
public class TestContainer extends Container {
private Label testLabel;
public Label getTestLabel() {
Label containerElement = getContainer().testLabel;
if(containerElement == null) {
getContainer().testLabel = new Label(this.containerElements.get("testLabel"),
"testLabel", this);
}
return getContainer().testLabel;
}
}
Test code:
@Test
public void myLocatorTest() {
MyApp app = new MyApp();
System.out.println(app.getAnotherLabel().getLocator());
System.out.println(app.getExampleTestCustom().getLocator());
}
Resulting output:
//div[1]
null
@nirsch Thanks for the reproducible here. This does appear to be a bug.
this is fixed with c1ca533
I am experiencing weird behavior when a custom HTML element is defined within a Container of a PageYAML file. The resulting generated code incorrectly generates the getter for that element at the Page level instead of the Container level. The object mapping for the element exists within the Container mapping (as expected). Calling the getter at the Page level (as currently generated) results in a null locator being passed to the custom element, making that element unusable in the current implementation. What configuration is needed for it to generate within the Container?