我正在尝试查找匹配的字符串,然后使用Selenium IDE单击“回复”按钮。
我一直收到“未找到”错误。
我试过了:
/html/body/div[2]/article[2]/div[1]/a[3]/span[contains(text(), 'my-search-string')
示例HTML:
<article class="thread">
<div class="threadline normal first">
<span class="area" title="no location given">---</span>
<a href="?act=Q&ID=291557485" target="R" class="title">text?</a> <
<a href="?act=su&handle=my-search-string" target="R" class="handle">
<span class="handle hnd">my-search-string</span>
</a> >
<button class="BlockButton">Block</button>
<time>12:14</time>
</div> <!-- Added by edit -->
</article> <!-- Added by edit -->
或
<div class="threadline normal">
<span class="dotz"> : . . : . . : . . : . . : . . </span>
<a href="?act=Q&ID=291557031" target="R" class="title">some text</a> <
<a href="?act=su&handle=my-search-string" target="R" class="handle">
<span class="handle hnd">my-search-string</span>
</a> >
<button class="BlockButton">Block</button>
<time>12:03</time>
</div>
我收到错误:
'找不到'
如何使用Selenium IDE在表达式
中搜索字符串'my-search-string'<span class="handle hnd">my-search-string</span>
答案 0 :(得分:1)
Kantu Selenium IDE具有与页面源一起使用的sourceSearch和sourceExtract命令。因此,您可以使用此命令,而不是查看网页对象模型(DOM)并尝试查找正确的定位器。也支持正则表达式,但我想你在这里不需要它们。
所以在这种情况下你可以使用
{{1}}
答案 1 :(得分:0)
正确的XPath表达式是
/html/body/div[2]/article[2]/div[1]/a[2]/span[contains(text(), 'my-search-string')]
它的输出是:
我的搜索字符串
您错过了最后的]
,并且a
元素的索引被一个人拒绝了。
答案 2 :(得分:0)
尝试这个选择器:
//span[text()='my-search-string']
答案 3 :(得分:0)
您可以使用&#34; verifyAttribute&#34;:
命令:verifyAttribute
目标:目标@ class
价值:价值
示例:
命令:verifyAttribute
目标:/ html / body / div [2] / article [2] / div [1] / a [3] @href
值:?act = su&amp; handle = my-search-string
OBS:我不知道这是否适用于新的IDE,我使用旧版本2.9.1。