无法使用 Web 驱动程序获取 CSS 选择器"nth-type"



虽然已经能够使用简单的CSS(只包括id, name),但"n -type"放弃了。

下面是测试方法-

public static String GetTextByCSSSelector(IWebDriver webDriver, String cssLocator)
    {
        return webDriver.FindElement(By.CssSelector(cssLocator)).Text;
    }

这是方法调用-

GetTextByCSSSelector(_webDriver, "css=div#filelist div:nth-child(1)");

,这是例外-

OpenQA.Selenium.WebDriverException : An invalid or illegal string was specified

我在Selenium IDE中使用了上面提到的定位器,它确实突出显示了元素。猜吗?

#

另一个问题,你是否支持area - 51上的Selenium提案http://area51.stackexchange.com/proposals/4693/selenium你只需要点击提交按钮来支持网站,同时使用你的谷歌/雅虎账户登录。这个提议得到了SeleniumHQ的支持,我们需要更多的用户参与进来,让它看到光明。

#

试试div:first-child.

如果这是有效的,这意味着你只有CSS2能力,而不是CSS3能力。

从选择器中删除css=,并享受:)

最新更新