elc*_*rua 0 java selenium css-selectors selenium-webdriver
我如何才能转义以下特殊字符,以便可以使用div上的ID来获取表格?这是我的cssSelector:
#form > div:nth-child(4)>div:nth-child(2) > div:nth-of-type(2) > div:nth-of-type(2)
Run Code Online (Sandbox Code Playgroud)
这是html代码:
div id="form:panelGridTransactionInfo" class="ui-panel ui-widget ui-widget-content ui-corner-all"
Run Code Online (Sandbox Code Playgroud)
谢谢
您可以使用反斜杠将其转义,如下所示:
#form\:panelGridTransactionInfo > div:nth-child(4) > div:nth-child(2) > div:nth-of-type(2) > div:nth-of-type(2)
Run Code Online (Sandbox Code Playgroud)
在Java中,重复反斜杠以在字符串内进行自身转义:
"#form\\:panelGridTransactionInfo > div:nth-child(4) > div:nth-child(2) > div:nth-of-type(2) > div:nth-of-type(2)"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2589 次 |
| 最近记录: |