@@ -33,7 +33,6 @@ export function VegaChartPageProvider({
3333 const find = getService ( 'find' ) ;
3434 const testSubjects = getService ( 'testSubjects' ) ;
3535 const browser = getService ( 'browser' ) ;
36- const { common } = getPageObjects ( [ 'common' ] ) ;
3736 const retry = getService ( 'retry' ) ;
3837
3938 class VegaChartPage {
@@ -49,6 +48,15 @@ export function VegaChartPageProvider({
4948 return find . byCssSelector ( 'div.vgaVis__controls' ) ;
5049 }
5150
51+ public getYAxisContainer ( ) {
52+ return find . byCssSelector ( '[aria-label^="Y-axis"]' ) ;
53+ }
54+
55+ public async getAceGutterContainer ( ) {
56+ const editor = await this . getEditor ( ) ;
57+ return editor . findByClassName ( 'ace_gutter' ) ;
58+ }
59+
5260 public async getRawSpec ( ) {
5361 // Adapted from console_page.js:getVisibleTextFromAceEditor(). Is there a common utilities file?
5462 const editor = await this . getEditor ( ) ;
@@ -83,20 +91,16 @@ export function VegaChartPageProvider({
8391 }
8492
8593 public async typeInSpec ( text : string ) {
86- await this . focusEditor ( ) ;
94+ const aceGutter = await this . getAceGutterContainer ( ) ;
8795
88- let repeats = 20 ;
89- while ( -- repeats > 0 ) {
90- await browser . pressKeys ( Key . ARROW_UP ) ;
91- await common . sleep ( 50 ) ;
92- }
93- await browser . pressKeys ( Key . ARROW_RIGHT ) ;
96+ await aceGutter . doubleClick ( ) ;
97+ await browser . pressKeys ( Key . LEFT ) ;
98+ await browser . pressKeys ( Key . RIGHT ) ;
9499 await browser . pressKeys ( text ) ;
95100 }
96101
97102 public async cleanSpec ( ) {
98- const editor = await this . getEditor ( ) ;
99- const aceGutter = await editor . findByClassName ( 'ace_gutter' ) ;
103+ const aceGutter = await this . getAceGutterContainer ( ) ;
100104
101105 await retry . try ( async ( ) => {
102106 await aceGutter . doubleClick ( ) ;
@@ -107,11 +111,11 @@ export function VegaChartPageProvider({
107111 }
108112
109113 public async getYAxisLabels ( ) {
110- const chart = await testSubjects . find ( 'visualizationLoader' ) ;
111- const yAxis = await chart . findByCssSelector ( '[aria-label^="Y-axis"]' ) ;
114+ const yAxis = await this . getYAxisContainer ( ) ;
112115 const tickGroup = await yAxis . findByClassName ( 'role-axis-label' ) ;
113116 const labels = await tickGroup . findAllByCssSelector ( 'text' ) ;
114117 const labelTexts : string [ ] = [ ] ;
118+
115119 for ( const label of labels ) {
116120 labelTexts . push ( await label . getVisibleText ( ) ) ;
117121 }
0 commit comments