2017-05-22 178 views
0

我想测试查看密码按钮的功能,并测试我已经插入的密码。我想这将是简单的部分,难的部分是实际点击按钮来查看密码。我使用rspec来运行测试,而水豚与Mozilla Firefox进行交互。这是密码字段的代码,以及位于密码字段中的查看按钮。测试密码的输入

<span class="input-password-toggle-label" data-toggle="true" data-label-show="anzeigen" data-label-hide="verbergen" data-icon-show="<i class=&quot;icon icon-lg d-inline-block&quot;><svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; class=&quot;d-inline-block&quot; height=&quot;100%&quot; preserveAspectRatio=&quot;xMaxYMax meet&quot; width=&quot;100%&quot;> 
     <path d=&quot;M 12 5 C 6 5 1.3875 11.10625 1.1875 11.40625 C 0.8875 11.80625 0.8875 12.19375 1.1875 12.59375 C 1.3875 12.89375 6 19 12 19 C 18 19 22.6125 12.89375 22.8125 12.59375 C 23.1125 12.19375 23.1125 11.80625 22.8125 11.40625 C 22.6125 11.10625 18 5 12 5 z M 12 7 C 14.8 7 17 9.2 17 12 C 17 14.8 14.8 17 12 17 C 9.2 17 7 14.8 7 12 C 7 9.2 9.2 7 12 7 z M 12 9.5 C 10.619288 9.5 9.5 10.619288 9.5 12 C 9.5 13.380712 10.619288 14.5 12 14.5 C 13.380712 14.5 14.5 13.380712 14.5 12 C 14.5 10.619288 13.380712 9.5 12 9.5 z&quot;></path> 
    </svg></i>" data-icon-hide="<i class=&quot;icon icon-lg d-inline-block&quot;><svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; class=&quot;d-inline-block&quot; height=&quot;100%&quot; preserveAspectRatio=&quot;xMaxYMax meet&quot; width=&quot;100%&quot;> 
     <path d=&quot;M22.8,11.4C22.6,11.1,18,5,12,5S1.4,11.1,1.2,11.4c-0.3,0.4-0.3,0.8,0,1.2C1.4,12.9,6,19,12,19s10.6-6.1,10.8-6.4 C23.1,12.2,23.1,11.8,22.8,11.4z M12,17c-2.8,0-5-2.2-5-5c0-2.8,2.2-5,5-5s5,2.2,5,5C17,14.8,14.8,17,12,17z&quot;></path> 
    </svg></i>" style="display: inline;" title="verbergen"><i class="icon icon-lg d-inline-block"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="d-inline-block" height="100%" preserveAspectRatio="xMaxYMax meet" width="100%"> 
     <path d="M22.8,11.4C22.6,11.1,18,5,12,5S1.4,11.1,1.2,11.4c-0.3,0.4-0.3,0.8,0,1.2C1.4,12.9,6,19,12,19s10.6-6.1,10.8-6.4 C23.1,12.2,23.1,11.8,22.8,11.4z M12,17c-2.8,0-5-2.2-5-5c0-2.8,2.2-5,5-5s5,2.2,5,5C17,14.8,14.8,17,12,17z"></path> 
    </svg></i> 
</span> 

如果有人有任何想法,我将不胜感激。

+0

什么是你的问题? – reporter

+0

我不知道如何点击确定该视图,thingy,按钮或其他东西,实际上能够看到字母而不是*** – adizdar

回答

0

因为你的HTML中有元素存储在属性中,所以很难准确读出哪些是元素而不是字符串,以及你想要点击哪些元素。发布问题时更好地格式化您的HTML将有助于未来。为此,我认为你试图点击当前追加的< i>元素(我假定它在状态改变时被交换)。你可以用基本的CSS选择器来做到这一点

find('span.input-password-toggle-label i').click 
+0

这实际上工作,谢谢,我会尽力改善我的HTML格式,同时发布一个问题 – adizdar