繁体   English   中英

如果它包含jquery索引,则无法使用Selenium Explicit Wait

[英]I am unable to use Selenium Explicit Wait if it contains jquery index

我在硒webdriver显式等待中使用jquery索引"eq(1)" ,但它不起作用。

如果我从代码中删除此eq('" + Index + "') ,则它有效,但仅适用于第一个索引。 这个你能帮我吗。 谢谢

这是我要编写的代码,必须使用索引。

var elementClickable = new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("[data-uipath='" + uiPath + "'] :eq('" + Index + "')")));

您不能使用:eq() ,它不是Selenium中的有效选择器。 使用:nth-child代替。 请记住将+1添加到Index:eq()使用基于0的索引, :nth-child()使用基于1的索引

By.CssSelector("[data-uipath='" + uiPath + "']:nth-child(" + (Index + 1) +")")

尝试删除索引周围的引号,如下所示。 它可能会起作用。

var elementClickable = new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("[data-uipath='" + uiPath + "'] :eq(" + Index + ")")));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM