如何将 Selenium IDE 中的属性从子元素的父元素存储到变量

How to store an attribute in the Selenium IDE from the parent element of child to variable

我需要将属性“//images.wbstatic.net/promotions/wide/51597.jpg”存储到子变量“span class="countdown-hours"" 有人可以帮忙吗?

<img alt="Autumn Sale" src="//images.wbstatic.net/promotions/wide/51597.jpg">
<div class="countdown-container" data-end-time="\/Date(1444856400000+0300)\/" data-start-time="\/Date(1444805633216+0300)\/">
to the end is
<div class="countdown-timer">
    <span class="countdown-days">
        <span class="dots">:</span>
        <span class="countdown-hours">
            07
        <span>hours</span>
    </span>

您可以使用以下 XPath 获取 img 标签。

//div[@class='countdown-container'][.//span[@class = 'countdown-hours']]//preceding-sibling::img

xpath 找到 img 标签旁边的 div 标签,其中包含 span 和 class count-hours 并返回到 img 标签。