UNPKG

@christian-bromann/webdriverio

Version:

A nodejs bindings implementation for selenium 2.0/webdriver

64 lines (52 loc) 2.73 kB
describe('selectorChaining', () => { it('should find all .findme elements without any selector chaining', function () { return this.client.getText('.findme').then((elements) => elements.should.be.lengthOf(3)) }) it('should find only two .findme elements using selector chaining', function () { return this.client.element('.nested').getText('.findme').then( (elements) => elements.should.be.lengthOf(2)) }) it('should find only one element using double selector chaining', function () { return this.client.element('.nested').element('.moreNesting').getText('.findme').then( (elements) => elements.should.be.equal('MORE NESTED')) }) it('should loose selector restriction after calling another command', function () { return this.client.element('.nested').element('.moreNesting').getText('.findme').getText('.findme').then( (elements) => elements.should.be.lengthOf(3)) }) it('should be possible to keep selector empty if element was used before', function () { return this.client.element('.nested').element('.moreNesting').element('.findme').getText().then( (elements) => elements.should.be.equal('MORE NESTED')) }) it('should find deeply nested element using selector chaining', function () { return this.client.element('.nested').element('span=nested span').getText().then( (elements) => elements.should.be.equal('NESTED SPAN')) }) it('should select cell using context of row', function () { return this.client.elements('tr').then((rows) => { var foundRows = [] rows.value.forEach((element) => { var td1 = this.client.elementIdElement(element.ELEMENT, 'td=2015-03-02') var td2 = this.client.elementIdElement(element.ELEMENT, 'td=12:00') var p = Promise.all([td1, td2]).then(() => true, () => false) foundRows.push(p) }) return Promise.all(foundRows).then((rows) => { rows.should.be.an.instanceOf(Array) rows.should.have.length(2) rows[0].should.be.equal(true) rows[1].should.be.equal(true) }) }) }) it('should select cell with element as first citizen approach', function () { return this.client.element('tr').getText('td=2015-03-01').then((text) => { text.should.be.equal('2015-03-01') }) }) it('should not find td in other row', function () { return this.client.element('tr').isExisting('td=2015-03-02').then((isExisting) => { expect(isExisting).to.be.equal(false) }) }) })