diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeView.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeView.java index 096b6f0b4b..7733b0f22a 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeView.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeView.java @@ -24,12 +24,11 @@ public class TreeView extends UIBaseElement implements ISetup, IsLoading, ISelector, IsDense { protected static final String HOVERABLE_CORE_CLASS = "v-treeview--hoverable"; - protected static String nodesInCoreLocator = "./*[contains(@class, 'v-treeview-node')]"; - protected static String nodesAllLocator = ".v-treeview-node"; - protected static String checkboxFullyMarkedClass = "mdi-checkbox-marked"; - protected static String checkboxNotMarkedClass = "mdi-checkbox-blank-outline"; - - protected static String nodesInNodeLocator = + protected String nodesInCoreLocator = "./*[contains(@class, 'v-treeview-node')]"; + protected String nodesAllLocator = ".v-treeview-node"; + protected String checkboxFullyMarkedClass = "mdi-checkbox-marked"; + protected String checkboxNotMarkedClass = "mdi-checkbox-blank-outline"; + protected String nodesInNodeLocator = "./*[contains(@class, 'v-treeview-node__children')]/*[contains(@class, 'v-treeview-node')]"; protected static String rootInNodeLocator = "./*[contains(@class, 'v-treeview-node__root')]"; protected int startIndex = ELEMENT.startIndex; @@ -48,8 +47,6 @@ public void setup(Field field) { thisParent = true; } - // @todo #5322 New locator affects all classes, as they change static values - // Should be fixed to use instance variables private void initializeLocators(JDITreeView annotation) { if (!annotation.core().isEmpty()) { setCore(TreeView.class, $(annotation.core())); @@ -97,8 +94,10 @@ public TreeViewNode node(int index) { @JDIAction("Get '{name}' list of nodes") public List treeViewNodes() { return childNodes().stream() - .map(webElement -> new TreeViewNode().setCore(TreeViewNode.class, webElement)) - .collect(Collectors.toList()); + .map(webElement -> + new TreeViewNode(checkboxFullyMarkedClass, checkboxNotMarkedClass, nodesInNodeLocator) + .setCore(TreeViewNode.class, webElement) + ).collect(Collectors.toList()); } @JDIAction("Get if '{name}' is hoverable") @@ -111,11 +110,12 @@ public int size() { return childNodes().size(); } - @JDIAction("Get '{name}' size") + @JDIAction("Get '{name}' count of all nodes (children, grandchildrens, ...)") public int fullSize() { return allNodes().size(); } + // @todo #5401 Check that implementation is optimal @JDIAction("Expand all nodes in '{name}'") public void expandAllNodes() { treeViewNodes().forEach(TreeViewNode::expand); diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeViewNode.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeViewNode.java index a0d52d391b..893cbb20f1 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeViewNode.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/TreeViewNode.java @@ -40,13 +40,36 @@ public class TreeViewNode extends UIBaseElement implements protected static final String DISABLED_NODE_CLASS = "v-treeview-node--disabled"; protected static final String ACTIVE_ROOT_CLASS = "v-treeview-node--active"; - protected static String toggleLocator = ".v-treeview-node__toggle"; - protected static String checkboxLocator = ".v-treeview-node__checkbox"; - protected static String contentLocator = ".v-treeview-node__content"; + protected String toggleLocator = ".v-treeview-node__toggle"; + protected String checkboxLocator = ".v-treeview-node__checkbox"; + protected String contentLocator = ".v-treeview-node__content"; + + // can be changed in Ctor + protected String checkboxFullyMarkedClass = "mdi-checkbox-marked"; + protected String checkboxNotMarkedClass = "mdi-checkbox-blank-outline"; + protected String nodesInNodeLocator = + "./*[contains(@class, 'v-treeview-node__children')]/*[contains(@class, 'v-treeview-node')]"; + - protected final String delimiter = "/"; protected int startIndex = ELEMENT.startIndex; + public TreeViewNode() { + super(); + } + + public TreeViewNode(String full, String empty, String nodesInNode) { + super(); + if (full != null && !full.isEmpty()) { + this.checkboxFullyMarkedClass = full; + } + if (empty != null && !empty.isEmpty()) { + this.checkboxNotMarkedClass = empty; + } + if (nodesInNode != null && !nodesInNode.isEmpty()) { + this.nodesInNodeLocator = nodesInNode; + } + } + @JDIAction("Get if '{name}' is a leaf") public boolean isLeaf() { @@ -60,12 +83,12 @@ public boolean isActive() { @JDIAction("Get if '{name}' is fully marked") public boolean isFullyMarked() { - return checkbox().hasClass(TreeView.checkboxFullyMarkedClass); + return checkbox().hasClass(this.checkboxFullyMarkedClass); } @JDIAction("Get if '{name}' is not marked") public boolean isNotMarked() { - return checkbox().hasClass(TreeView.checkboxNotMarkedClass); + return checkbox().hasClass(this.checkboxNotMarkedClass); } @Override @@ -144,7 +167,7 @@ public WebList list() { return checkList(); } expand(); - return core().finds(TreeView.nodesInNodeLocator); + return core().finds(this.nodesInNodeLocator); } @JDIAction("Get '{name}' list of nodes")