2017-07-16 112 views
0

我正在使用codeception尝试单击,选择我的表单中的选项。问题是,当我尝试检查复选框时,它会选择隐私信息href链接,与我希望它选择的复选框相对。Codeception select选项

<div class="row"> 
 
    <div class="myclass"> 
 
    <div class="mb"> 
 
     <label class=" custom-checkbox"><input type="checkbox" id="from_accept" name="fform[accept]" class="custom-checkbox__input" value="1"> 
 
\t <span class="custom-checkbox__text"> 
 
     ::before 
 
      "I agree to terms " 
 
\t <a href="[there is a link here]">terms and conditions</a> 
 
      "and some more text here " 
 
\t  <a href="[there is a link here]">privacy info</a> 
 
     "." 
 
     ::after 
 
\t </span> 
 
    </label> 
 
    </div> 
 
    </div> 
 
</div>

我已经试过的Xpath & CSS选择器,但没有运气,甚至悬停让我发现,它看到的只是最后的href锚链接。

+1

你能告诉我们你的工作吗?谢谢 – DebanjanB

回答

0

这里是回答你的问题:

请尝试以下xpath

//div[@class='row']/div[@class='myclass']/div[@class='mb']/label[@class=' custom-checkbox' and @class='custom-checkbox__input']//self::label 

注意,有一个空白(即空间)内class=" custom-checkbox"

设我知道这个答案是否是您的问题。

+0

感谢您的建议,它很接近,但它继续选择最后一个锚标签...? – toddy

+0

另外我修改了代码..因为有一些::之前::之后......行。不知道这是否有所作为? – toddy

+0

@toddy根据更新的HTML,实现所需的步骤会有点棘手。如果网址是公开网址,您可以与我们分享吗? 同时检查我更新的答案并让我知道状态。感谢 – DebanjanB