7 |
7 |
import org.openqa.selenium.By;
|
8 |
8 |
import org.openqa.selenium.WebDriver;
|
9 |
9 |
import org.openqa.selenium.WebElement;
|
10 |
|
import org.openqa.selenium.interactions.Actions;
|
11 |
|
|
12 |
|
import java.util.Arrays;
|
13 |
|
import java.util.List;
|
14 |
10 |
|
15 |
11 |
public class DetailsTest {
|
16 |
12 |
|
17 |
13 |
static WebDriver browser;
|
18 |
14 |
|
19 |
|
public static final String VISIBLE_Q_TIP_XPATH = "//div[contains(@class, 'qtip') and @aria-hidden='false']";
|
20 |
|
|
21 |
15 |
@BeforeAll
|
22 |
16 |
public static void initTest() {
|
23 |
17 |
SeleniumUtil.prepareConfigFile("emptyConfig.json");
|
... | ... | |
27 |
21 |
|
28 |
22 |
@Test
|
29 |
23 |
public void vertexDetail(){
|
30 |
|
checkQTip(
|
31 |
|
vertexQTip("vertex1"),
|
32 |
|
"V1 (3)",
|
33 |
|
Arrays.asList("D: E", "B: W", "A: Q")
|
34 |
|
);
|
35 |
|
|
36 |
|
checkQTip(
|
37 |
|
vertexQTip("vertex2"),
|
38 |
|
"V2 (2)",
|
39 |
|
Arrays.asList("D: E", "C: Q", "B: W")
|
40 |
|
);
|
41 |
|
|
42 |
|
checkQTip(
|
43 |
|
vertexQTip("vertex3"),
|
44 |
|
"V3 (1)",
|
45 |
|
Arrays.asList("D: Q", "C: W", "A: E")
|
46 |
|
);
|
|
24 |
checkPopover(vertexPopover("V1"),"V1 (3)\nD: E\nB: W\nA: Q");
|
|
25 |
|
|
26 |
checkPopover(vertexPopover("V2"),"V2 (2)\nD: E\nC: Q\nB: W");
|
|
27 |
|
|
28 |
checkPopover(vertexPopover("V3"),"V3 (1)\nD: Q\nC: W\nA: E");
|
47 |
29 |
}
|
48 |
30 |
|
49 |
31 |
@Test
|
50 |
32 |
public void edgeDetail() {
|
51 |
|
checkQTip(
|
52 |
|
edgeQTip("e1"),
|
53 |
|
"Edge Details",
|
54 |
|
Arrays.asList(
|
55 |
|
"edgeArchetype1", "D : E", "C : W"
|
56 |
|
)
|
57 |
|
);
|
58 |
|
|
59 |
|
checkQTip(
|
60 |
|
edgeQTip("e2"),
|
61 |
|
"Edge Details",
|
62 |
|
Arrays.asList(
|
63 |
|
"edgeArchetype1", "D : E", "B : W", "A : Q",
|
64 |
|
"edgeArchetype2", "D : D", "B : S", "A : A"
|
65 |
|
)
|
66 |
|
);
|
67 |
|
|
68 |
|
checkQTip(
|
69 |
|
edgeQTip("e3"),
|
70 |
|
"Edge Details",
|
71 |
|
Arrays.asList(
|
72 |
|
"edgeArchetype2", "C : T", "B : R"
|
73 |
|
)
|
74 |
|
);
|
75 |
|
}
|
76 |
|
|
|
33 |
checkPopover(edgePopover("1"),"Edge details\nedgeArchetype1\nD: E\nC: W");
|
77 |
34 |
|
78 |
|
private WebElement edgeQTip(String edgeElementId) {
|
79 |
|
WebElement arrow = browser.findElement(By.id(edgeElementId))
|
80 |
|
.findElement(By.className("arrow"));
|
|
35 |
checkPopover(edgePopover("2"),"Edge details\nedgeArchetype1\nD: E\nB: W\nA: Q\nedgeArchetype2\nD: D\nB: S\nA: A");
|
81 |
36 |
|
82 |
|
return getQTipElement(arrow);
|
|
37 |
checkPopover(edgePopover("3"),"Edge details\nedgeArchetype2\nC: T\nB: R");
|
83 |
38 |
}
|
84 |
39 |
|
85 |
|
private WebElement vertexQTip(String vertexElementId) {
|
86 |
|
WebElement archetypeIcon = browser.findElement(By.id(vertexElementId))
|
87 |
|
.findElement(By.className("archetype"));
|
88 |
|
|
89 |
|
return getQTipElement(archetypeIcon);
|
90 |
|
}
|
91 |
40 |
|
92 |
|
private WebElement getQTipElement(WebElement toClick) {
|
93 |
|
SeleniumUtil.svgClick(toClick);
|
|
41 |
private WebElement edgePopover(String edgeId) {
|
|
42 |
WebElement arrow = browser.findElement(By.cssSelector("[data-id='edges']"))
|
|
43 |
.findElement(By.cssSelector("[data-id='" + edgeId + "']"))
|
|
44 |
.findElement(By.className("arrow"));
|
94 |
45 |
|
95 |
|
return browser.findElement(By.xpath(VISIBLE_Q_TIP_XPATH));
|
|
46 |
SeleniumUtil.svgClick(arrow);
|
|
47 |
return browser.findElement(By.className("edge-popover"));
|
96 |
48 |
}
|
97 |
49 |
|
98 |
|
private void checkQTip(WebElement qTipElement, String expectedTitle, List<String> expectedAttributes) {
|
99 |
|
QTip qtip = new QTip(qTipElement);
|
100 |
|
|
101 |
|
System.out.println("Title: " + qtip.getTitle());
|
102 |
|
Assertions.assertEquals(expectedTitle, qtip.getTitle());
|
|
50 |
private WebElement vertexPopover(String vertexElementName) {
|
|
51 |
WebElement archetypeIcon = browser.findElement(By.cssSelector("[data-id='vertices']"))
|
|
52 |
.findElement(By.cssSelector("[data-name='" + vertexElementName + "']"))
|
|
53 |
.findElement(By.className("archetype-icon"));
|
103 |
54 |
|
104 |
|
List<String> attributes = qtip.getAttributes();
|
105 |
|
System.out.println("Attributes:");
|
106 |
|
for (String attr : attributes) {
|
107 |
|
System.out.println(attr);
|
108 |
|
}
|
109 |
|
Assertions.assertEquals(expectedAttributes, attributes);
|
|
55 |
SeleniumUtil.svgClick(archetypeIcon);
|
|
56 |
return browser.findElement(By.className("vertex-popover"));
|
|
57 |
}
|
110 |
58 |
|
111 |
|
qtip.close();
|
112 |
|
Assertions.assertFalse(qtip.isVisible());
|
|
59 |
private void checkPopover(WebElement popoverElement, String expectedText) {
|
|
60 |
String text = popoverElement.getText();
|
|
61 |
Assertions.assertEquals(expectedText, text);
|
113 |
62 |
}
|
114 |
63 |
|
115 |
64 |
@AfterAll
|
Repaired Seleninum tests - DetailsTest