Ruby/Selenium xpath html 属性

Ruby/Selenium xpath html attribute

我需要帮助

是否可以从这样的结构中提取值 Developer:

<h2 class="Title">
       WEB <em>Developer</em>    
</h2>

或者像这样(我需要 bluh-bluh-bluh。Developer bluh bluh):

<p class="Description">
        bluh-bluh-bluh. <em>Developer</em> bluh bluh
</p>

我试过了

title = driver.find_element(:css, ".******").attribute('????')

我的命令找到元素,但没有提取属性

那不是属性。使用正确的选择器并获得 text 应该有效

选择器:h2>em

使用

title = driver.find_element(:css, "h2>em").text