Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access child element via wdio

Tags:

webdriver-io

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"

like image 724
Ramesh Avatar asked Oct 21 '25 04:10

Ramesh


1 Answers

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

like image 134
Vojtech Cerveny Avatar answered Oct 24 '25 01:10

Vojtech Cerveny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!