测试密码的输入



我正在尝试测试查看密码按钮的功能,并测试我已经插入的密码。我想这将是容易的部分,困难的部分是实际单击按钮以查看密码。我正在使用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>

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

由于您的 HTML 具有存储在属性中的元素,因此很难准确读取哪些是元素而不是字符串,以及您究竟要单击哪些元素。在发布问题时更好地格式化您的 HTML 将在未来有所帮助。 为此,我认为您正在尝试单击外部 span 元素内当前附加的元素(我假设它会随着状态的变化而交换)。 您可以使用基本的CSS选择器来做到这一点

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

最新更新