@@ -71,8 +71,8 @@ export class TreeView {
71
71
await t . click ( this . treeViewSettingsBtn ) ;
72
72
await t . click ( this . sortingBtn ) ;
73
73
order === 'ASC'
74
- ? await t . click ( this . sortingASCoption )
75
- : await t . click ( this . sortingDESCoption )
74
+ ? await t . click ( this . sortingASCoption )
75
+ : await t . click ( this . sortingDESCoption ) ;
76
76
77
77
// Click on save button
78
78
await t . click ( this . treeViewDelimiterValueSave ) ;
@@ -93,11 +93,11 @@ export class TreeView {
93
93
*/
94
94
async openTreeFolders ( names : string [ ] ) : Promise < void > {
95
95
let base = `node-item_${ names [ 0 ] } :` ;
96
- await t . click ( Selector ( `[data-testid=" ${ base } "]` ) ) ;
96
+ await this . clickElementIfNotExpanded ( base , names [ 0 ] ) ;
97
97
if ( names . length > 1 ) {
98
98
for ( let i = 1 ; i < names . length ; i ++ ) {
99
99
base = `${ base } ${ names [ i ] } :` ;
100
- await t . click ( Selector ( `[data-testid=" ${ base } "]` ) ) ;
100
+ await this . clickElementIfNotExpanded ( base , names [ i ] ) ;
101
101
}
102
102
}
103
103
}
@@ -120,4 +120,17 @@ export class TreeView {
120
120
121
121
return textArray ;
122
122
}
123
+
124
+ /**
125
+ * click on the folder element if it is not expanded
126
+ * @param base the base element
127
+ * @param name of the folder
128
+ */
129
+ private async clickElementIfNotExpanded ( base : string , name : string ) : Promise < void > {
130
+ const folderArrow = Selector ( `[data-test-subj="node-arrow-icon_"${ name [ 0 ] } "]` ) ;
131
+ const baseSelector = Selector ( `[data-testid="${ base } "]` ) ;
132
+ if ( await baseSelector . find ( 'div' ) . count === 0 && await folderArrow . exists ) {
133
+ await t . click ( Selector ( `[data-testid="${ base } "]` ) ) ;
134
+ }
135
+ }
123
136
}
0 commit comments