XPath to CSS Selector

前端 未结 1 1071
暗喜
暗喜 2021-02-11 09:18

I have the following xpath statement in a selenium test:

//tbody/tr[td/span[text()=\'IPODate\']]/td[4]/input

It gets what I want but my tests a

相关标签:
1条回答
  • 2021-02-11 09:44

    the CSS locator is css=span.CN for the span that has the text IPODate in it.

    Saucelabs have a good explanaton of how it works on their blog

    UPD: Unfortunately CSS won't parse the entire tree when move up and down till it finds what it is after. This is the main reason why XPath is so slow. CSS finds an item and then can move laterally through the DOM. The CSS below will find the input box that is after the TD that has class=TCN which holds your span with text in the table.

    CSS: table > tbody > tr > td.TCN + td + td > input

    0 讨论(0)
提交回复
热议问题