【问题标题】:Test Codeception/webdriver And Dynamic Form ID测试 Codeception/webdriver 和动态表单 ID
【发布时间】:2014-08-13 12:33:51
【问题描述】:

只是一个问题,我尝试使用在每次刷新时动态生成的 ID 对表单执行验收测试(填写字段)。我正在寻找一种方法来获取表单id,或者使用部分xpath,我没有找到。

<input type="text"     name="searchform_fb1831c63342af1bc6b8744181e2cc5b[simpleCriteria][NAME]"     id="searchform_fb1831c63342af1bc6b8744181e2cc5b-simpleCriteria-NAME" value=""     size="40" class="manage_ul_error text-input">

欢迎任何建议谢谢。

【问题讨论】:

    标签: xpath webdriver codeception dynamicform


    【解决方案1】:

    一种选择是检查id 属性是否包含searchform_

    //input[@type='text' and contains(@id, 'searchform_')]
    

    或者,开始于:

    //input[@type='text' and starts-with(@id, 'searchform_')]
    

    您也可以另外检查class

    //input[@type='text' and @class='manage_ul_error text-input' and starts-with(@id, 'searchform_')]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-21
      • 1970-01-01
      • 2016-06-05
      • 1970-01-01
      • 1970-01-01
      • 2017-03-21
      • 1970-01-01
      相关资源
      最近更新 更多