Get Child object of a given element
See original GitHub issueHi, When using the Get WebElements keyword am getting a list of elements that fits my locator. Each element contains a child object, how can I get the child one?
example:
<a class="yt-uix-sessionlink spf-link " data-sessionlink="itct=CGEQlDUYAyITCOeh4-OEvM8CFQKkHAodw6QFfSiOHjIGZy1oaWdoWg9GRXdoYXRfdG9fd2F0Y2g" href="/watch?v=5i-94at2SDA" aria-hidden="true">
<div class="yt-thumb video-thumb">
<span class="yt-thumb-simple">
<img height="110" width="196" data-ytimg="1" alt="" src="https://i.ytimg.com/vi/5i-94at2SDA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=YqxUUk-Z6HgOYPKBVVuMA9o1iaU" onload=";__ytRIL(this)">
</span>
</div>
<span class="**video-time**" aria-hidden="true">**3:34**</span>
/a>
I want to get the “video-time” inside a random a> element, is it possible?
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (9 by maintainers)
Top Results From Across the Web
Getting Child Elements of a Node in JavaScript
In this tutorial, you will learn how to get the first child element, last child element, and all elements of a specified element....
Read more >Getting the child objects from an object and create new ones ...
Here is one way to build an array with the three properties : $children = []; foreach( $parent->getChildren() as $child ){ $children[] ...
Read more >Finding child objects by type and property values
All children of a specific object can be obtained via object.children(). This article concerns itself with only finding objects by certain ...
Read more >Element.children - Web APIs - MDN Web Docs
Element.children includes only element nodes. To get all child nodes, including non-element nodes like text and comment nodes, use Node.
Read more >Scripting API: Transform.GetChild - Unity - Manual
In this case "Transform child out of bounds" error will be given. ... of the first child of the Game Object this script...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is direct message, you can use execute script to create a varaible.
so i created a keyword
it takes two argument parent(Webelement) and child(Xpath) to search for child inside the parent.
Assuming parent xpath to as :
//ul[@id="top_menu"]
, the above code will search for equalent xpath//ul[@id="top_menu"]/./h3
note taht context is parent and not rootso this will be equalent to xpath
For SeleniumLibrary versions 5.0 and above, you can use chained locators.