import { ElementFinder , browser , by , ElementArrayFinder , ProtractorBrowser } from 'protractor' ; import { waitForPresence } from '../utilities/utils' ; export abstract class Component { component : ElementFinder ; protected byCss ( css , root = this . component ) { return root . element ( by . css ( css ) ) ; } protected byCssText ( css , text , root = this . component ) { return root . element ( by . cssContainingText ( css , text ) ) ; } protected byId ( css , root = this . component ) { return root . element ( by . id ( css ) ) ; } protected byTitleAttr ( title , root = this . component ) { return root . element ( by . css ( `[title=${ title }]` ) ) ; } protected allByCss ( css , root = this . component ) { return root . all ( by . css ( css ) ) ; } protected constructor ( selector , ancestor ? ) { const locator = selector ; this . component = ancestor ? browser . $$ ( ancestor ) . first ( ) . $$ ( locator ) . first ( ) : browser . $$ ( locator ) . first ( ) ; } async wait ( ) { await waitForPresence ( this . component ) ; } }