1

编辑:

我的 CSSSelector 是这样的:(在 FF 中运行良好)

for (int i = 1; i < _count; i++)
{
    ..................
    ..................
    div#ctl00_ContentPlaceHolder1 table.gv tbody tr.item:nth-child(" + i + ") > td:nth-of-type(3)
    ..................

}

编辑结束

我在 FF 中使用 Selenium 2.29 和 IE (8) 和 FF (17.1) 我的所有测试用例都通过了,当我在 IE 中运行时,我的大多数测试用例都失败了,这是错误消息:

Test method threw exception: 
OpenQA.Selenium.WebDriverTimeoutException: Timed out after 30 seconds ---> OpenQA.Selenium.NoSuchElementException: 
Unable to find element with css selector == 

div#ctl00_ContentPlaceHolder1 table.gv tbody tr.item:nth-child(1) > td:nth-of-type(3)

我正在使用 CSSSelector。

我是否必须更改 CSSSelector 才能使 IE 工作?

4

3 回答 3

6

根据:http ://www.quirksmode.org/css/contents.html#t38

IE8 及以下不支持:nth选择器。

于 2013-02-04T17:57:55.003 回答
0

IE8 不支持 CSS nth-of-type

于 2013-02-04T17:58:46.440 回答
0

由于 IE8 不支持 :nth 选择器,请尝试注入 Sizzle。Sizzle(jQuery 使用的选择器引擎)带有一个内置的:nth-child()选择器,但缺少一个:nth-of-type()选择器。尝试:nth-of-type:nth-child

于 2013-02-06T14:46:46.870 回答