selenium.type("css=div#J_MS_Form form input:nth-child(2)","b")
selenium.type("css=div#J_MS_Form form input:nth-of-type(2)","b")
用css怎么都没有取到,这个问题要怎么解决呢?
谢谢!
[ 本帖最后由 小米啊 于 2010-7-13 19:32 编辑 ]作者: goal1860 时间: 2010-6-29 10:53
Can you give the url you are testing?作者: 小米啊 时间: 2010-6-29 12:00
我有提供的,上面的 实验地址
谢谢!
[ 本帖最后由 小米啊 于 2010-7-13 19:32 编辑 ]作者: 测试侠 时间: 2010-7-13 09:41
直接用css=input[value='b'],不行吗作者: goal1860 时间: 2010-7-14 09:18
Sorry for the late response, pretty bust recently, guess you have figured out the answer
The correct expression is:
selenium.type("css=div#J_MDG_Form form input:nth-child(4)","b")
You may noticed that I made 2 changes:
- MS -> MDG, don't know the reason, taobao may changed their code.
- nth-child(2) -> nth-child(4). The 2nd input which you look for is actually 4th children. "input:nth-child(2)" means the 2nd children which is "input", may be different against your initial assumption.
Personally I am strongly against css locators sicne the big compatibility problem accross browsers. Both of these 2 pseudo classes are not support by IE. As functional testing, performace is not the No1 priority. Maintainabilty is something on top of my mind.作者: 小米啊 时间: 2010-8-10 16:37 标题: 回复 5# 的帖子 谢谢!
css=cssSelectorSyntax: Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.
css=a[href="#id3"]
css=span#firstChild + span
Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, nly-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).