diff --git a/docs/locators.md b/docs/locators.md index 9704f6b5b..c1e9c7b87 100644 --- a/docs/locators.md +++ b/docs/locators.md @@ -137,6 +137,15 @@ Finds an element which contains a child element provided: locate('form').withChild('select'); ``` +#### withDescendant + +Finds an element which contains a descendant element provided: + +```js +// finds form with + +
+ +
@@ -106,6 +112,15 @@ describe('Locator', () => { expect(nodes[0].firstChild.data).to.eql('Please click', l.toXPath()); }); + + it('should select child element by name', () => { + const l = Locator.build('.form-field') + .withDescendant(Locator.build('//input[@name="name1"]')); + const nodes = xpath.select(l.toXPath(), doc); + + expect(nodes).to.have.length(1, l.toXPath()); + }); + it('should select element by siblings', () => { const l = Locator.build('//table') .withChild('td')