不明白为什么以下循环不起作用,除了具有相同类的第 n 个元素在第二个元素上失败(我假设第一个元素有效,因为它也是 xpath 中的根):
{
"Command": "storeEval",
"Target": "$('.className').length",
"Value": "max"
},
{
"Command": "store",
"Target": "1",
"Value": "i"
},
{
"Command": "while",
"Target": "(${i} < ${max})",
"Value": ""
},
{
"Command": "echo",
"Target": "Current value of i = ${i}",
"Value": "i"
},
{
"Command": "storeAttribute",
"Target": "//a[contains(@class, 'className')][${i}]@href",
"Value": "link"
},
{
"Command": "endWhile",
"Target": "",
"Value": ""
}
对于调试,我尝试更改...[${i}]
为[2]
Kantu 和 Ranorex Selocity 都失败了。但是,根据我对 xpath / Selenium IDE 文档的阅读,这种语法应该是正确的。有什么建议吗?
PS。作为参考,.className
实际上是.rf-project-cover__title
在页面https://www.behance.net/search?field=132&content=projects&sort=published_date&time=week