Ramesh
Ramesh

Reputation: 61

How to access child element via wdio

Below code is for finding parent. What needs to be passed instead of ".." to access child?

const parent = paragraph.$('..')

console.log(parent.getTagName()) // outputs: "body"

Upvotes: 4

Views: 7901

Answers (1)

Vojtech Cerveny
Vojtech Cerveny

Reputation: 696

Do you know which elements are you looking for? Check these examples:

paragraph.$$('//*')      // find all childs
paragraph.$('a')         // find first child link
paragraph.$('*=Submit')  // find first child element which contains 'Submit'

You can use any locator strategy as you want - CSS, XPath, TagName or by text. Check documentation

Upvotes: 4

Related Questions