Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions x-pack/test/functional/page_objects/graph_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function GraphPageProvider({ getService, getPageObjects }: FtrProviderCon
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'header']);
const retry = getService('retry');
const browser = getService('browser');

class GraphPage {
async selectIndexPattern(pattern: string) {
Expand Down Expand Up @@ -124,9 +125,12 @@ export function GraphPageProvider({ getService, getPageObjects }: FtrProviderCon

async getGraphObjects() {
await this.stopLayout();
const graphElements = await find.allByCssSelector(
'#graphSvg line, #graphSvg circle, #graphSvg text.gphNode__label'
);
// read node labels directly from DOM because getVisibleText is not reliable for the way the graph is rendered
const nodeNames: string[] = await browser.execute(`
const elements = document.querySelectorAll('#graphSvg text.gphNode__label');
return [...elements].map(element => element.innerHTML);
`);
const graphElements = await find.allByCssSelector('#graphSvg line, #graphSvg circle');
const nodes: Node[] = [];
const nodePositionMap: Record<string, number> = {};
const edges: Edge[] = [];
Expand All @@ -136,15 +140,10 @@ export function GraphPageProvider({ getService, getPageObjects }: FtrProviderCon
const tagName: string = await element.getTagName();
// check the position of the circle element
if (tagName === 'circle') {
nodes.push({ circle: element, label: '' });
nodes.push({ circle: element, label: nodeNames[nodes.length] });
const position = await this.getCirclePosition(element);
nodePositionMap[position] = nodes.length - 1;
}
// get the label for the node from the text element
if (tagName === 'text') {
const text = await element.getVisibleText();
nodes[nodes.length - 1].label = text;
}
}

// find all edges
Expand Down