Yes,you can do that using selenium-webdriver
and :xpath
. Take a look at the below example:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://en.wikipedia.org/wiki/Ruby_(programming_language)"
driver.find_element(:xpath,"//span[@class = 'mw-headline' and text() = 'Ruby 1.0' ]").tag_name
# => "span"
driver.find_element(:xpath,"//span[@class = 'mw-headline' and text() = 'Ruby 1.0' ]").text
# => "Ruby 1.0"
This example is fully equivalent to your html
code. Now try to create your xpath
,by taking the help of the above. You will get success.