saresend / selenium-rs

A Rust Client for the Selenium webdriver (WIP)
MIT License
176 stars 31 forks source link

Finding Elements within Elements #36

Open nixpulvis opened 3 years ago

nixpulvis commented 3 years ago

I'm pretty used to the Ruby gem which has some pretty ergonomic interfaces. The first one I notice myself reaching for is the Find implementation on the Element class. This makes it possible to do something like the following:

driver.find_elements(class: 'article').each do |article|
    title = article.find_element(class: 'title').text
    date = article.find_element(class: 'date').text
    body = article.find_elements(tag_name: 'p').last.text
end

I'm not sure what the best way to emulate this functionality is today, nor do I actually know how it's implemented in Ruby to be honest. It's just really nice to have.