I have a page with multiple entries of student names, each student having an url that leads to his chart. The html looks like this:
<a target="_blank" data-tn-element="grade-result-link" data-tn-link
href="/johndoe/b89db3308ddaaed2?sp=0" rel="nofollow" class="student_link"
<span class="graduated"> - Graduated 2013</span>
results = page.all('div.student_name').map do |item|
urls = page.all('div.student_name a', minimum: 1).map do |link] link[:href] end
should get you the urls. The
minimum:1 would just make the
all wait until at least one instance is on the page and may not be needed in your particular instance. Depending on the driver you're using they may be full normalized urls but stripping the domain off them isn't hard if you really need relative.