summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/att/ecomp/dcae/ci/ui/rule_editor/components/actions/ActionComponent.java
blob: c12931a7f3b7d43e1665b0d54cce8496549a1147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.att.ecomp.dcae.ci.ui.rule_editor.components.actions;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.att.ecomp.dcae.ci.ui.rule_editor.components.BaseComponenet;
import com.att.ecomp.dcae.ci.ui.utils.ByTest;
import com.att.ecomp.dcae.ci.ui.utils.Locator;
import com.att.ecomp.dcae.ci.utilities.Report;
import com.aventstack.extentreports.Status;

public class ActionComponent extends BaseComponenet {

	public ActionComponent(WebDriverWait timeout, WebElement element) {
		super(timeout, element);
	}
	
	public void delete() {
		Report.log(Status.INFO, "click on delete action");
		wait.until(Locator.from(root).findVisible(ByTest.id("deleteAction"), 0)).click();
	}
	
	public void setTarget(String target) {
		Report.log(Status.INFO, "Filling input target...");
		getTargetElement().clear();
		getTargetElement().sendKeys(target);
	}
	
	public void setTargetFromTree(){
		Report.log(Status.INFO, "Pick target from tree");
		wait.until(Locator.from(root).findVisible(ByTest.id("openTargetTree"), 0)).click();
		Report.log(Status.INFO, "Click on tree toggle");
		wait.until(Locator.from(root).findVisible(ByTest.cssSelector(".toggle-children-wrapper"),0)).click();
		Report.log(Status.INFO, "Click on first target node");
		wait.until(Locator.from(root).findVisible(ByTest.id("targetNode"), 1)).click();
	}
	
	public String getTarget() {
		Report.log(Status.INFO, "get input target...");
		return getTargetElement().getAttribute("value");
	}
	
	/* Private Methods */
	
	private WebElement getTargetElement() {
		return wait.until(Locator.from(root).findVisible(ByTest.id("inputTarget"), 0));
	}
}