当前位置:优学网  >  在线题库

如何查找输入字段的XPath

发表时间:2022-07-29 00:45:12 阅读:108

HTML:

<div class="v-input__control"><div class="v-input__slot"><div class="v-text-field__slot"><input id="input-357" type="text"></div></div><div class="v-text-field__details"><div 

I tried this:

//*[text()='Enter Phone Number']/following-sibling::*//input  

But got no success.

🎖️ 优质答案
  • 您缺少标记名xpath=//标记名[@attribute=value]

  • 构造xpath时,表达式需要以tag_name开始,例如.&ltdiv&gt&lttable&gt等,或者以.*`*开头,前面总是有双正斜杠,即//`


    解决方案

    实际上,您的代码行将是:

    //*[text()='Enter Phone Number']//following-sibling::input[1]
    
  • 相关问题