Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98827

How to find previous WebElements relative to a particular WebElement with selenium python

$
0
0

I have the below HTML snippet.

<div class="header">Planets</div>
<div class="event">Jupiter</div>
<div class="event">Mars</div>

<div class="header">Stars</div>
<div class="event">Acturus</div>
<div class="event">Pleaides</div>

Using driver.find_elements_by_class_name("event"), I am able to retrieve all the div tags with class "event".

I would want to navigate to the previous sibling and retrieve the div tag with class "header" for each WebElement.


Viewing all articles
Browse latest Browse all 98827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>