Skip to content

Commit ddc4cd9

Browse files
committed
Add UIB features to servicenow module
1 parent 89d42eb commit ddc4cd9

4 files changed

Lines changed: 5 additions & 121 deletions

File tree

bellatrix.servicenow/src/main/java/solutions/bellatrix/servicenow/components/uiBuilder/UiBuilderRecordChoice.java

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
import solutions.bellatrix.servicenow.components.enums.UibComponentType;
44
import solutions.bellatrix.web.components.Button;
5+
import solutions.bellatrix.web.components.WebComponent;
56
import solutions.bellatrix.web.components.contracts.ComponentDisabled;
67
import solutions.bellatrix.web.components.contracts.ComponentText;
78
import solutions.bellatrix.web.components.shadowdom.ShadowRoot;
89

910
import java.util.List;
1011

1112
public class UiBuilderRecordChoice extends UIBDefaultComponent implements ComponentDisabled, ComponentText {
12-
// protected WebComponent customUiDropdown() {
13-
// return this.shadowRootCreateByCss(WebComponent.class, "sn-record-choice").getShadowRoot();
14-
// }
13+
protected WebComponent customUiDropdown() {
14+
return this.shadowRootCreateByCss(WebComponent.class, "sn-record-choice").getShadowRoot();
15+
}
1516

1617
public ShadowRoot dropdown() {
1718
return this.createByXPath(ShadowRoot.class, ".//now-select").getShadowRoot();
@@ -37,60 +38,6 @@ public Button getOptionByText(String text) {
3738
return optionFound.get();
3839
}
3940

40-
// @Override
41-
// public String getText() {
42-
// return dropdownButton().getText();
43-
// }
44-
//
45-
// @Override
46-
// public boolean isDisabled() {
47-
// return dropdownButton().isDisabled();
48-
// }
49-
//
50-
// @Override
51-
// public UibComponentType componentType() {
52-
// return UibComponentType.CHOICE;
53-
// }
54-
//
55-
// public void click() {
56-
// dropdownButton().click();
57-
// }
58-
//
59-
// public void selectByIndex(int index) {
60-
// try {
61-
// click();
62-
// browserService.waitForAjax();
63-
// getOptionByIndex(index).click();
64-
// } catch (ElementNotInteractableException exception) {
65-
// getOptionByIndex(index).scrollToVisible();
66-
// getOptionByIndex(index).click();
67-
// }
68-
// }
69-
//
70-
// public void selectByText(String text) {
71-
// try {
72-
// click();
73-
// browserService.waitForAjax();
74-
// getOptionByText(text).click();
75-
// } catch (ElementNotInteractableException exception) {
76-
// getOptionByText(text).scrollToVisible();
77-
// getOptionByText(text).click();
78-
// }
79-
// }
80-
//
81-
// public String getName() {
82-
// return getAttribute("name");
83-
// }
84-
//
85-
// @Override
86-
// public void setText(String text) {
87-
// selectByText(text);
88-
// }
89-
//
90-
// public void assertSelectionIs(String expectedText) {
91-
// validateTextIs(expectedText);
92-
// }
93-
//}
9441
@Override
9542
protected ShadowRoot getDropDownWrapper() {
9643
return create().byXPath(ShadowRoot.class, "//now-popover-panel/descendant::seismic-hoist").getShadowRoot();
@@ -115,5 +62,4 @@ public UibComponentType componentType() {
11562
public String getText() {
11663
return this.getWrappedElement().getAttribute("value");
11764
}
118-
11965
}

bellatrix.servicenow/src/main/java/solutions/bellatrix/servicenow/pages/uib/pages/baseUIBPage/BaseUIBPage.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ protected <FormClass extends ServiceNowForm> void fillForm(FormClass model, Web
144144
var choice = ((UiBuilderRecordChoice)component);
145145
choice.dropdownButton().click();
146146
choice.getOptionByText(field.get(model).toString()).click();
147-
// choice.getOptionByText(field.get(model).toString());
148147
} else {
149148
component.getShadowRoot().createByCss(TextInput.class,"input" ).getWrappedElement().sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE, field.get(model).toString(), Keys.ENTER);
150149
}
@@ -160,49 +159,6 @@ protected <FormClass extends ServiceNowForm> void fillForm(FormClass model, Web
160159
throw new RuntimeException("Failed to read field value for label: %s".formatted(elementLabel), e);
161160
}
162161
}
163-
164-
// if (field.isAnnotationPresent(UibComponent.class) && field.isAnnotationPresent(FieldLabel.class)) {
165-
// var componentClass = field.getDeclaredAnnotation(UibComponent.class).value();
166-
// var elementLabel = field.getDeclaredAnnotation(FieldLabel.class).value();
167-
//
168-
// try {
169-
// var foundComponentWrappers = container.createAllByXPath(componentClass, String.format(".//*[contains(name(),'sn-record-') and descendant::*[text()='%s']]", elementLabel)).stream().findAny();
170-
// if (foundComponentWrappers.isPresent()) {
171-
//
172-
// var component = foundComponentWrappers.get();
173-
// Method setTextMethod = getSetTextMethod(componentClass);
174-
// Object setTextValue = null;
175-
// try {
176-
// setTextValue = field.get(model);
177-
// setTextMethod.invoke(component, setTextValue);
178-
// } catch (Exception e) {
179-
// throw new RuntimeException("Fill Form failed with Error.", e);
180-
// }
181-
// }
182-
//
183-
// }
184-
// catch (IllegalArgumentException | NotFoundException iae) {
185-
// Log.info("Form Field with label: '%s' Not found".formatted(elementLabel));
186-
// }
187-
// catch (Exception e) {
188-
// throw new RuntimeException("Failed to read field value for label: %s".formatted(elementLabel), e);
189-
// }
190-
// }
191-
192-
193-
// // Refactor after read and Assert are working as expected
194-
// var componentClass = field.getDeclaredAnnotation(UibComponent.class).value();
195-
// var elementId = field.getDeclaredAnnotation(Id.class).value();
196-
// var component = formComponent.createByXPath(componentClass, String.format(".//*[@id='%s']", elementId));
197-
//
198-
// Method setTextMethod = getSetTextMethod(componentClass);
199-
// Object setTextValue = null;
200-
// try {
201-
// setTextValue = field.get(model);
202-
// setTextMethod.invoke(component, setTextValue);
203-
// } catch (Exception e) {
204-
// throw new RuntimeException("Fill Form failed with Error.", e);
205-
// }
206162
}
207163
}
208164

bellatrix.servicenow/src/main/java/solutions/bellatrix/servicenow/pages/uib/sections/mainContentSection/MainContentSection.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,6 @@ public Anchor noRecordDisplayLabel() {
5757
return getActiveScreen().createByXPath(Anchor.class, ".//h2[text()='No records to display.']");
5858
}
5959

60-
61-
//
62-
// public WorkOrdersFilterComponent getWorkOrderFilter() {
63-
// return getActiveScreen().createByXPath(WorkOrdersFilterComponent.class, ".//now-record-list-panel");
64-
// }
65-
//
66-
// public Button preChecklistButton() {
67-
// return getActiveScreen().
68-
// createByCss(Button.class, "#item-card_base_container_8");
69-
// }
70-
71-
72-
73-
74-
7560
public Button getEssentialsSectionTilesText(String value) {
7661
var xpath = String.format(".//h4[text()= '%s']", value);
7762
return getActiveScreen()

getting-started/bellatrix.servicenow.getting.started/src/test/java/O8_UIB/uibTableView/UibTableViewTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,4 @@ public void openRecordByColumnValue() {
106106
allWorkPage.filterByColumnValue("column_name", "column_value");
107107
allWorkPage.openRecordFromDataGrid("column_name", "column_value");
108108
}
109-
}
110-
111-
112-
109+
}

0 commit comments

Comments
 (0)