gpt4 book ai didi

selenium - Selenium 中的动态 x 路径中的输入及其属性不断变化

转载 作者:行者123 更新时间:2023-12-02 21:33:48 25 4
gpt4 key购买 nike

我尝试查找文本字段用户名密码的x路径,但它不断动态变化。我将无法使用starts-with或使用 x 路径的 findelement 中的 contains。这是 HTML DOM-

      <div id="contents">
<h1 style="white-space:pre; width:80px; float:left;line-height:35px;">Login</h1>
<span style="float:left; padding-top:13px; COLOR:#990033; font-weight:bold;"> Student | Parent | Faculty</span>
<div class="form-elements">
<div class="form-elements">
<div class="form-elements">
<div class="label-txt">Password</div>
<input id="rcnr2uew1m0rkikeaaniwk" type="password" style="display:none;" name="rcnr2uew1m0rkikeaaniwk"/>
<input id="ko2xs123ebqyoluh15bulu" type="password" style="display:none;" name="ko2xs123ebqyoluh15bulu"/>
<input id="cuouek4bfz41etm4hroj0r" type="password" style="display:none;" name="cuouek4bfz41etm4hroj0r"/>
<input id="u2ta3gv2o2ce0azx5plpuh" type="password" name="u2ta3gv2o2ce0azx5plpuh"/>
<input id="g03nwjuzhqnkuwgsl4q2mu" type="password" style="display:none;" name="g03nwjuzhqnkuwgsl4q2mu"/>
<input id="gddwv4z3amojk0yvoxi2v4" type="password" style="display:none;" name="gddwv4z3amojk0yvoxi2v4"/>
<input id="kxecmkho2vf1vcfb42icjr" type="password" style="display:none;" name="kxecmkho2vf1vcfb42icjr"/>
<span id="ctl04" style="color:Red;visibility:hidden;">*</span>
</div>

我试图找到没有样式的输入[4]。

绝对 x 路径 - html/body/form/div[3]/div[1]/div[2]/div[1]/div[1]/div[1]/div[2 ]/输入[4]

下次它会如何变化-

绝对 x 路径 - html/body/form/div[3]/div[1]/div[2]/div[1]/div[1]/div[1]/div[2 ]/输入[17]

idnameinput也不断变化,没有任何共同特征

最佳答案

您可以通过找到显示的用户名标签的同级标签来完成此操作,即没有属性style="display:none;"

用户名

"//div[contains(text(), 'User Name')]/following-sibling::input[not(@style='display:none;')]"

密码

"//div[contains(text(), 'Password')]/following-sibling::input[not(@style='display:none;')]"

关于selenium - Selenium 中的动态 x 路径中的输入及其属性不断变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42041750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com