import { $ , browser , ElementArrayFinder , ElementFinder } from 'protractor' ; export class SparkPage { singleValueChart = $ ( '#single-value' ) ; multiValueChart = $ ( '#multi-value' ) ; async getPage ( ) { await browser . get ( '#/spark' ) ; } getSegments ( chart ) { return chart . $$ ( '.ux-spark-bar' ) ; } async getSparkHeight ( chart ) { return await chart . $ ( '.ux-spark' ) . getCssValue ( 'height' ) ; } async getSegmentWidth ( segment ) { return parseInt ( await segment . getCssValue ( 'width' ) ) ; } async getTheme ( chart ) { const element = chart . $ ( '.ux-spark' ) ; const classes = await element . getAttribute ( 'class' ) ; return classes . split ( ' ' ) . find ( className => className . trim ( ) . indexOf ( 'ux-spark-theme' ) === 0 ) ; } async getTopLeftLabel ( chart ) { try { return await chart . $ ( '.ux-spark-label-top-left' ) . getText ( ) ; } catch ( err ) { return null ; } } async getTopRightLabel ( chart ) { try { return await chart . $ ( '.ux-spark-label-top-right' ) . getText ( ) ; } catch ( err ) { return null ; } } async getBottomLeftLabel ( chart ) { try { return await chart . $ ( '.ux-spark-label-bottom-left' ) . getText ( ) ; } catch ( err ) { return null ; } } async getBottomRightLabel ( chart ) { try { return await chart . $ ( '.ux-spark-label-bottom-right' ) . getText ( ) ; } catch ( err ) { return null ; } } async getAriaLabel ( chart ) { return await chart . $ ( '.ux-spark' ) . getAttribute ( 'aria-label' ) ; } async getSegmentAriaLabels ( chart ) { const segments = await this . getSegments ( chart ) ; const labels = [ ] ; for ( let idx = 0 ; idx < segments . length ; idx ++ ) { const label = await segments [ idx ] . getAttribute ( 'aria-label' ) ; if ( label ) { labels . push ( label ) ; } } return labels ; } }