1

如何在动态生成但最后一部分保持不变的下拉列表 ID 上使用 Selenium IDE 以命令结尾?

我试过了

    select
    id=ends-with(@id, "_gridDropDownList")
    label=A

    select
    xpath=//name[ends-with(@id, "_gridDropDownList")]
    label=A

但我收到一个错误,即找不到元素或 xpath 无效。

这是HTML:

    <td class="select-field district2-field blogLocationAndTopicFields">
    <label></label>
    <select
    id="ctl00_m_g_a5a2d9db_4beb_87c2_ce5e339b9858_ctl00_gridDropDownList"
    class=""
    name="ctl00$m$g_a5a2d9db_4beb_87c2_ce5e339b9858$ctl00$gridDropDownList"
    style="background-color: rgb(255, 255, 255);"></select>

谢谢你的帮助...

4

2 回答 2

0

我没有 selenium IDE 来验证,但我强烈怀疑这部分是无效的:

id=ends-with(@id, "_gridDropDownList")

函数ends-with()返回布尔值,id您的代码与之比较的最有可能不是布尔值。我猜你想substring-before()改用:

id=substring-before(@id, "_gridDropDownList")
于 2015-03-08T02:57:18.253 回答
0

如果html标签的所有属性都是动态的。

例如:

select id="0ef13ca7-905d-42c7-8e9a-0a94a1d71ceeF_EditIOT-widget-select" class="freedomSelect notDojoDndHandle" aria-required="false" dojoattachevent="onchange:onChange, onfocus:onFocus, onblur:onBlur" dojoattachpoint="comboNode, containerNode, focusNode"

并且select[ends-with(@id,'EditIOT-widget-select')]不起作用,我们可以使用子字符串的“包含”函数瞬间并以函数结尾。

尝试这个:

select[contains(@id, 'EditIOT-widget-select')]
于 2016-06-07T15:38:36.090 回答