2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.datatypes;
23 import com.aventstack.extentreports.Status;
24 import com.clearspring.analytics.util.Pair;
25 import com.google.gson.JsonElement;
26 import com.google.gson.JsonParser;
27 import org.apache.commons.lang3.tuple.ImmutablePair;
28 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
29 import org.openecomp.sdc.ci.tests.datatypes.enums.CircleSize;
30 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
31 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
32 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
33 import org.openecomp.sdc.ci.tests.pages.PropertiesAssignmentPage;
34 import org.openecomp.sdc.ci.tests.pages.PropertyNameBuilder;
35 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
36 import org.openqa.selenium.By;
37 import org.openqa.selenium.StaleElementReferenceException;
38 import org.openqa.selenium.WebElement;
39 import org.openqa.selenium.interactions.Actions;
40 import org.testng.Assert;
41 import org.testng.SkipException;
44 import java.util.concurrent.TimeUnit;
45 import java.util.stream.Collectors;
47 public final class CanvasManager {
48 private Map<String, CanvasElement> canvasElements;
49 private Actions actions;
50 private WebElement canvas;
51 private int reduceCanvasWidthFactor;
52 private CanvasElement canvasElement;
53 // Offsets Are used to find upper right corner of canvas element in order to
55 private static final int CANVAS_VF_Y_OFFSET = 30;
56 private static final int CANVAS_VF_X_OFFSET = 18; // 14 - 27
58 private static final int CANVAS_NORMATIVE_ELEMENT_Y_OFFSET = 12;
59 private static final int CANVAS_NORMATIVE_ELEMENT_X_OFFSET = 7;
61 private static final int CANVAS_SERVICE_Y_OFFSET = 27;
62 private static final int CANVAS_SERVICE_X_OFFSET = 16;
64 private CanvasManager() {
65 canvasElements = new HashMap<>();
66 actions = new Actions(GeneralUIUtils.getDriver());
67 canvas = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS.getValue());
69 WebElement webElement = GeneralUIUtils
70 .getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS_RIGHT_PANEL.getValue());
71 reduceCanvasWidthFactor = webElement.getSize().width;
72 } catch (Exception e) {
73 reduceCanvasWidthFactor = 0;
77 public static CanvasManager getCanvasManager() {
78 return new CanvasManager();
81 public List<CanvasElement> getCanvasElements() {
82 return canvasElements.values().stream().collect(Collectors.toList());
85 private void addCanvasElement(CanvasElement element) {
86 String prefix = element.getElementType();
87 List<CanvasElement> canvasElementsFromSameTemplate = new ArrayList<>();
89 // collect all elements from from same template
90 for(CanvasElement currElement:canvasElements.values()){
91 if(currElement.getElementNameOnCanvas().toLowerCase().startsWith(prefix.toLowerCase())){
92 canvasElementsFromSameTemplate.add(currElement);
96 // match element name to actual name on canvas
97 if( canvasElementsFromSameTemplate.size() > 0){
98 String newName = prefix + " " + canvasElementsFromSameTemplate.size();
99 element.setElementNameOnCanvas(newName);
102 canvasElements.put(element.getUniqueId(), element);
105 private void moveElementOnCanvas(CanvasElement canvasElement, ImmutablePair<Integer, Integer> newLocation)
107 GeneralUIUtils.waitForLoader();
108 actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right);
109 actions.clickAndHold();
110 actions.moveToElement(canvas, newLocation.left, newLocation.right);
113 canvasElement.setLocation(newLocation);
114 GeneralUIUtils.waitForLoader();
118 public void moveToFreeLocation(String containerName) {
120 int sumOfWaiting = 0;
122 boolean isKeepWaiting = false;
123 while (!isKeepWaiting) {
124 ImmutablePair<Integer, Integer> freePosition = getFreePosition();
125 actions.moveToElement(canvas, freePosition.left, freePosition.right);
126 actions.clickAndHold();
129 isKeepWaiting = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText()
130 .equals(containerName);
131 sumOfWaiting += napPeriod;
132 if (sumOfWaiting > maxWait) {
133 Assert.fail("Can't click on VF");
138 public void clickOnCanvaElement(CanvasElement canvasElement) {
139 // actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right);
140 ImmutablePair<Integer, Integer> coordinates = getElementCoordinates(canvasElement.getElementNameOnCanvas());
141 actions.moveToElement(canvas, coordinates.left, coordinates.right);
142 actions.clickAndHold();
145 GeneralUIUtils.ultimateWait();
146 actions.click().perform();
147 GeneralUIUtils.ultimateWait();
149 validateInstanceSelected(canvasElement);
150 ExtentTestActions.log(Status.INFO, String.format("Canvas element %s selected", canvasElement.getElementType()));
153 public void openLinkPopupReqsCapsConnection(CanvasElement canvasElement)
155 ExtentTestActions.log(Status.INFO, "Open Link popup");
156 clickOnCanvasLink(canvasElement);
157 int x = canvasElement.getLocation().getLeft() + 30; // view button x delta
158 int y = canvasElement.getLocation().getRight() + 11; // view button y delta
159 clickOnCanvasPosition(x,y);
160 GeneralUIUtils.ultimateWait();
163 public void openLinkPopupReqsCapsConnection(CanvasElement sourceElement, CanvasElement destElement)
165 ExtentTestActions.log(Status.INFO, "Open Link popup");
166 ImmutablePair<Integer, Integer> sourceCoordinates = getElementCoordinates(sourceElement.getElementNameOnCanvas());
167 ImmutablePair<Integer, Integer> destCoordinates = getElementCoordinates(destElement.getElementNameOnCanvas());
168 ImmutablePair<Integer, Integer> linkPosition = calcMidOfLink(sourceCoordinates, destCoordinates);
170 clickOnCanvasPosition(linkPosition.left, linkPosition.right); // click on link
171 int x = linkPosition.left + 30;
172 int y = linkPosition.right + 11;
173 clickOnCanvasPosition(x,y); // click on view popup
174 GeneralUIUtils.ultimateWait();
177 public void closeLinkPopupReqsCapsConnection()
179 GeneralUIUtils.clickOnElementByTestId("Cancel");
180 // GeneralUIUtils.ultimateWait();
183 public void clickSaveOnLinkPopup()
185 ExtentTestActions.log(Status.INFO, "Click save on link popup");
186 GeneralUIUtils.clickOnElementByTestId("Save");
187 // GeneralUIUtils.ultimateWait();
190 public void deleteLinkPopupReqsCapsConnection(CanvasElement canvasElement)
192 ExtentTestActions.log(Status.INFO, "Delete Link ");
193 clickOnCanvasLink(canvasElement);
194 int x = canvasElement.getLocation().getLeft() + 30; // delete button x delta
195 int y = canvasElement.getLocation().getRight() + 30; // delete button x delta
196 clickOnCanvasPosition(x,y);
199 public void deleteLinkPopupReqsCapsConnection(CanvasElement sourceElement, CanvasElement destElement)
201 ExtentTestActions.log(Status.INFO, "Delete Link ");
202 ImmutablePair<Integer, Integer> sourceCoordinates = getElementCoordinates(sourceElement.getElementNameOnCanvas());
203 ImmutablePair<Integer, Integer> destCoordinates = getElementCoordinates(destElement.getElementNameOnCanvas());
204 ImmutablePair<Integer, Integer> linkPosition = calcMidOfLink(sourceCoordinates, destCoordinates);
205 clickOnCanvasPosition(linkPosition.left, linkPosition.right); // click on link
206 int x = linkPosition.left + 30; // delete button x delta
207 int y = linkPosition.right + 30; // delete button y delta
208 clickOnCanvasPosition(x,y);
211 public void clickOnCanvasLink(CanvasElement canvasElement) {
212 actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right);
213 actions.click().perform();
214 GeneralUIUtils.ultimateWait();
217 public void clickOnCanvasPosition(int x, int y) {
220 actions.moveToElement(canvas, x, y);
223 GeneralUIUtils.ultimateWait();
227 System.out.println(e);
231 public void moveElementOnCanvas(CanvasElement canvasElement) throws Exception {
232 moveElementOnCanvas(canvasElement, getFreePosition());
235 public void deleteElementFromCanvas(CanvasElement canvasElement) throws Exception {
236 GeneralUIUtils.waitForLoader();
237 actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right);
240 ExtentTestActions.log(Status.INFO, String.format("Removing canvas element %s ", canvasElement.getElementType()));
241 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue())
243 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.DELETE_INSTANCE_CANCEL.getValue()).click();
244 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue())
246 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.DELETE_INSTANCE_OK.getValue()).click();
247 canvasElements.remove(canvasElement.getUniqueId());
248 GeneralUIUtils.ultimateWait();
249 if (canvasElement.getElementType().contains("-")){
250 ExtentTestActions.log(Status.INFO, String.format("Canvas element %s is removed", canvasElement.getElementType().split("-")[4]));
253 ExtentTestActions.log(Status.INFO, String.format("Canvas element %s is removed", canvasElement.getElementType()));
257 private WebElement findClickElement(String dataTestId) {
259 while (attempts < 2) {
261 return GeneralUIUtils.getWebElementByTestID(dataTestId);
262 } catch (StaleElementReferenceException e) {
269 public CanvasElement createElementOnCanvas(String elementName) throws Exception {
270 String actionDuration = GeneralUIUtils.getActionDuration(() -> {
272 canvasElement = createElementOnCanvasWithoutDuration(elementName);
273 } catch (Exception e) {
278 if (canvasElement != null){
279 ExtentTestActions.log(Status.INFO, String.format("The element %s should now be on the canvas", elementName), actionDuration);
281 return canvasElement;
284 private CanvasElement createElementOnCanvasWithoutDuration(String elementDataTestId) throws Exception {
286 CompositionPage.searchForElement(elementDataTestId);
287 WebElement element = findClickElement(elementDataTestId);
288 ImmutablePair<Integer, Integer> freePosition = getFreePosition();
289 actions.moveToElement(element, 20, 20);
290 actions.clickAndHold();
291 actions.moveToElement(canvas, freePosition.left, freePosition.right);
294 GeneralUIUtils.ultimateWait();
295 String uniqueId = elementDataTestId + "_" + UUID.randomUUID().toString();
296 CanvasElement canvasElement = new CanvasElement(uniqueId, freePosition, elementDataTestId);
297 addCanvasElement(canvasElement);
298 GeneralUIUtils.ultimateWait();
299 return canvasElement;
301 catch (Exception e) {
302 System.out.println("Can't create element on canvas");
308 public CanvasElement createElementOnCanvas(LeftPanelCanvasItems canvasItem) throws Exception {
309 return createElementOnCanvas(canvasItem.getValue());
312 private ImmutablePair<Integer, Integer> getFreePosition() {
313 ImmutablePair<Integer, Integer> randomPosition = null;
314 boolean freePosition = false;
316 while (!freePosition) {
317 ImmutablePair<Integer, Integer> tempRandomPosition = getRandomPosition();
318 freePosition = !canvasElements.values().stream().map(e -> e.getLocation())
319 .filter(e -> Math.abs(e.left - tempRandomPosition.left) < minSpace
320 && Math.abs(e.right - tempRandomPosition.right) < minSpace)
321 .findAny().isPresent();
322 randomPosition = tempRandomPosition;
324 return randomPosition;
327 private ImmutablePair<Integer, Integer> getRandomPosition() {
329 Random random = new Random();
330 int xElement = random.nextInt(canvas.getSize().width - 2 * edgeBuffer - reduceCanvasWidthFactor) + edgeBuffer;
331 int yElement = random.nextInt(canvas.getSize().height - 2 * edgeBuffer) + edgeBuffer;
332 return new ImmutablePair<Integer, Integer>(xElement, yElement);
335 // Will work only if 2 elements are big sized (VF size), if one of the elements is Small use the function linkElements
336 public void linkElements(CanvasElement firstElement, CanvasElement secondElement) throws Exception {
337 ExtentTestActions.log(Status.INFO, String.format("Linking between the %s instance and the %s instance.", firstElement.getElementType(), secondElement.getElementType()));
338 drawSimpleLink(firstElement.getElementNameOnCanvas(), secondElement.getElementNameOnCanvas());
339 selectReqAndCapAndConnect();
340 ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement.getElementType(), secondElement.getElementType()));
343 // old version, depricated
344 public void linkElements(CanvasElement firstElement, CircleSize firstElementSize, CanvasElement secondElement, CircleSize secondElementSize) throws Exception {
345 drawSimpleLink(firstElement,firstElementSize, secondElement,secondElementSize);
346 selectReqAndCapAndConnect();
347 ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement.getElementType(), secondElement.getElementType()));
350 public void linkElements(String firstElement, String secondElement) throws Exception {
351 drawSimpleLink(firstElement, secondElement);
352 selectReqAndCapAndConnect();
353 ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement, secondElement));
356 // use JS to get coordinates of elements
357 private void drawSimpleLink(String firstElement, String secondElement) {
358 ImmutablePair<Integer, Integer> firstElementCoordinates = getGreenDotCoordinatesOfElement(firstElement);
359 ImmutablePair<Integer, Integer> secondElementCoordinates = getElementCoordinates(secondElement);
361 actions.moveToElement(canvas, firstElementCoordinates.left, firstElementCoordinates.right);
363 actions.moveToElement(canvas, firstElementCoordinates.left, firstElementCoordinates.right);
364 actions.clickAndHold();
365 actions.moveToElement(canvas, secondElementCoordinates.left, secondElementCoordinates.right);
368 GeneralUIUtils.ultimateWait();
371 private void selectReqAndCapAndConnect() throws Exception {
372 addFirstReqOrCapAndPressNext();
373 addFirstReqOrCapAndPressNext();
374 linkMenuClickOnFinishButton();
377 private void addFirstReqOrCapAndPressNext() throws Exception {
379 linkMenuClickOnNextButton();
382 private void addFirstReqOrCap() {
383 GeneralUIUtils.getWebElementsListByClassName(DataTestIdEnum.LinkMenuItems.LINK_ITEM_CAP_Or_REQ.getValue()).get(0).click();
386 private void linkMenuClickOnNextButton() throws Exception {
387 GeneralUIUtils.clickOnElementByText("Next");
388 GeneralUIUtils.ultimateWait();
391 private void linkMenuClickOnFinishButton() throws Exception {
392 GeneralUIUtils.clickOnElementByText("Finish");
393 GeneralUIUtils.ultimateWait();
397 private void drawSimpleLink(CanvasElement firstElement, CanvasElement secondElement) throws Exception {
398 int yOffset = CANVAS_VF_Y_OFFSET;
399 int xOffset = CANVAS_VF_X_OFFSET;
401 actions.moveToElement(canvas, firstElement.getLocation().left + xOffset,
402 firstElement.getLocation().right - yOffset);
404 actions.clickAndHold();
405 actions.moveToElement(canvas, secondElement.getLocation().left + xOffset, secondElement.getLocation().right - yOffset);
408 GeneralUIUtils.ultimateWait();
411 private void drawSimpleLink(CanvasElement firstElement, CircleSize firstElementSize, CanvasElement secondElement, CircleSize secondElementSize) throws Exception {
412 ExtentTestActions.log(Status.INFO, String.format("Linking between the %s instance and the %s instance.", firstElement.getElementType(), secondElement.getElementType()));
413 Integer yOffset = getCircleOffset(firstElementSize).right;
414 Integer xOffset = getCircleOffset(firstElementSize).left;
415 firstElement.getElementType();
418 actions.moveToElement(canvas, firstElement.getLocation().left + xOffset,
419 firstElement.getLocation().right - yOffset);
421 actions.clickAndHold();
423 yOffset = getCircleOffset(secondElementSize).right;
424 xOffset = getCircleOffset(secondElementSize).left;
426 actions.moveToElement(canvas, secondElement.getLocation().left + xOffset, secondElement.getLocation().right - yOffset);
430 GeneralUIUtils.ultimateWait();
433 private Pair<Integer,Integer> getCircleOffset(CircleSize circleSize)
435 Pair<Integer,Integer> circleSizes;
436 if(circleSize.equals(CircleSize.VF))
438 circleSizes = new Pair <Integer,Integer> (CANVAS_VF_X_OFFSET,CANVAS_VF_Y_OFFSET);
440 else if (circleSize.equals(CircleSize.NORMATIVE))
442 circleSizes = new Pair <Integer,Integer> (CANVAS_NORMATIVE_ELEMENT_X_OFFSET,CANVAS_NORMATIVE_ELEMENT_Y_OFFSET);
446 circleSizes = new Pair <Integer,Integer> (CANVAS_SERVICE_X_OFFSET,CANVAS_SERVICE_Y_OFFSET);
451 public String updateElementNameInCanvas(CanvasElement canvasElement, String newInstanceName) throws Exception {
452 GeneralUIUtils.ultimateWait();;
453 clickOnCanvaElement(canvasElement);
454 GeneralUIUtils.getWebElementBy(By.id("editPencil")).click();
455 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.RENAME_INSTANCE_CANCEL.getValue()).click();
456 GeneralUIUtils.getWebElementBy(By.id("editPencil")).click();
457 WebElement instanceNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.INSTANCE_NAME_FIELD.getValue());
458 String oldInstanceName = instanceNameField.getAttribute("value");
459 instanceNameField.clear();
460 instanceNameField.sendKeys(newInstanceName);
461 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.RENAME_INSTANCE_OK.getValue()).click();
462 GeneralUIUtils.ultimateWait();
463 GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("w-sdc-modal-resource-instance-name"));
464 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Name of element instance changed from %s to %s", oldInstanceName, newInstanceName));
465 return oldInstanceName;
469 * @param canvasElement
470 * Validate that instance was selected on right sidebar
472 public void validateInstanceSelected(CanvasElement canvasElement) {
474 long sumOfWaiting = 0;
475 long napPeriod = 200;
476 boolean isInstanceSelected;
478 isInstanceSelected = CompositionPage.getSelectedInstanceName().toLowerCase().contains(canvasElement.getElementType().toLowerCase());
480 if (!isInstanceSelected) {
482 TimeUnit.MILLISECONDS.sleep(napPeriod);
483 } catch (InterruptedException e) {
488 sumOfWaiting += napPeriod;
489 if (sumOfWaiting > maxWait) {
490 throw new SkipException(String.format("Bug 342260, can't select instance properly, waited for %s seconds after click on instance", (int) (maxWait/1000)));
492 } while (!isInstanceSelected);
495 public void validateLinkIsSelected() {
497 long sumOfWaiting = 0;
498 long napPeriod = 200;
499 boolean isInstanceSelected;
501 isInstanceSelected = GeneralUIUtils.isWebElementExistByClass("w-sdc-menu-item w-sdc-canvas-menu-item-view");
503 if (!isInstanceSelected) {
505 TimeUnit.MILLISECONDS.sleep(napPeriod);
506 } catch (InterruptedException e) {
511 sumOfWaiting += napPeriod;
512 if (sumOfWaiting > maxWait) {
513 Assert.fail(String.format("Can't select link properly, waited for %s seconds", (int) (maxWait/1000)));
515 } while (!isInstanceSelected);
518 private void selectReqCapByName(String reqCapName)
520 GeneralUIUtils.clickOnElementByText(reqCapName);
521 GeneralUIUtils.ultimateWait();
524 private void selectTypeOfReqCap(String dataTestId, String reqCapType)
526 GeneralUIUtils.selectByValueTextContained(dataTestId, reqCapType);
529 public void linkElementsAndSelectCapReqTypeAndCapReqName(CanvasElement firstElement, CanvasElement secondElement, ConnectionWizardPopUpObject connectionWizardPopUpObject) throws Exception {
530 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating link between %s and %s", firstElement.getElementType(), secondElement.getElementType()));
531 // drawSimpleLink(firstElement, firstElementSize, secondElement, secondElementSize);
532 drawSimpleLink(firstElement.getElementNameOnCanvas(), secondElement.getElementNameOnCanvas());
533 selectTypeOfReqCap(DataTestIdEnum.LinkMenuItems.REQ_CAP_SELECT_DATA_TESTS_ID.getValue(),connectionWizardPopUpObject.getCapabilityTypeSecondItem());
534 addFirstReqOrCapAndPressNext();
535 selectReqCapByName(connectionWizardPopUpObject.getCapabilityNameSecondItem());
536 linkMenuClickOnNextButton();
537 linkMenuClickOnFinishButton();
540 public Map<String, String> linkElementsWithCapPropAssignment(CanvasElement firstElement, CanvasElement secondElement, ConnectionWizardPopUpObject connectionWizardPopUpObject) throws Exception {
541 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating link between %s and %s", firstElement.getElementType(), secondElement.getElementType()));
542 drawSimpleLink(firstElement.getElementNameOnCanvas(), secondElement.getElementNameOnCanvas());
543 selectTypeOfReqCap(DataTestIdEnum.LinkMenuItems.REQ_CAP_SELECT_DATA_TESTS_ID.getValue(),connectionWizardPopUpObject.getCapabilityTypeSecondItem());
544 addFirstReqOrCapAndPressNext();
545 selectReqCapByName(connectionWizardPopUpObject.getCapabilityNameSecondItem());
546 linkMenuClickOnNextButton();
547 Map<String, String> mapOfValues = connectionWizardAssignCapPropValues();
548 linkMenuClickOnFinishButton();
555 public Map<String, String> connectionWizardAssignCapPropValues() throws Exception{
556 //get list of capability property value fields data-tests-ids in connection wizard
557 List<String> valueField = getListOfValueFieldIDs();
558 //get map of field ids and their values, fill in values if empty
559 Map<String, String> propValues = getMapOfCapPropValues(valueField, true);
563 public Map<String, String> connectionWizardCollectCapPropValues() throws Exception{
564 //get list of capability property value fields data-tests-ids in connection wizard
565 List<String> valueField = getListOfValueFieldIDs();
566 //get map of field ids and their values, collect existing values
567 Map<String, String> propValues = getMapOfCapPropValues(valueField, false);
571 private List<String> getListOfValueFieldIDs() {
572 String propName = GeneralUIUtils.getWebElementsListByContainsClassName("multiline-ellipsis-content").get(0).getText();
573 List<WebElement> valueNameElement = GeneralUIUtils.findElementsByXpath("//div[@class='dynamic-property-row nested-level-1']/div[1]");
574 List<String> valueName = new ArrayList<>();
575 for(int i=0; i < valueNameElement.size(); i++){
576 valueName.add(valueNameElement.get(i).getText());
578 //get list of value field names as appear in data-tests-id
579 List<String> valueField = new ArrayList<>();
580 for(int i=0; i < valueName.size(); i++){
581 valueField.add(PropertyNameBuilder.buildIComplexField(propName, valueName.get(i)));
586 private Map<String, String> getMapOfCapPropValues(List<String> valueField, boolean isValueAssign) throws Exception {
587 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Assigning values to properties of capabilities and/or collecting existing ones"));
588 Map<String, String> propValues = new HashMap<>();
589 for(int i=0; i < valueField.size(); i++){
590 String fieldId = valueField.get(i);
591 if(GeneralUIUtils.getWebElementByTestID(fieldId).getAttribute("value").isEmpty() && isValueAssign) {
592 //add value and put into map
593 propValues.put(fieldId, "value" + i);
594 PropertiesAssignmentPage.editPropertyValue(fieldId, "value" + i);
596 //put existing value into map
597 propValues.put(fieldId, GeneralUIUtils.getWebElementByTestID(valueField.get(i)).getAttribute("value"));
604 public ImmutablePair<Integer, Integer> calcMidOfLink(ImmutablePair<Integer, Integer> location1, ImmutablePair<Integer, Integer> location2)
606 int x = (location1.getLeft()+location2.getLeft())/2;
607 int y = (location1.getRight()+location2.getRight())/2;
609 ImmutablePair<Integer, Integer> location = new ImmutablePair<>(x,y);
613 public ImmutablePair<Integer, Integer> getElementCoordinates(String elementName){
614 Object position = GeneralUIUtils.getElementPositionOnCanvas(elementName);
615 return converJSJsonToCoordinates(position);
618 public ImmutablePair<Integer, Integer> getGreenDotCoordinatesOfElement(String elementName){
619 Object position = GeneralUIUtils.getElementGreenDotPositionOnCanvas(elementName);
620 return converJSJsonToCoordinates(position);
623 public ImmutablePair<Integer, Integer> converJSJsonToCoordinates(Object position) {
624 JsonElement root = new JsonParser().parse(position.toString());
625 int xElement = root.getAsJsonObject().get("x").getAsInt();
626 int yElement = root.getAsJsonObject().get("y").getAsInt();
627 return new ImmutablePair<Integer, Integer>(xElement, yElement);