带有相邻同级组合器的 Selenium RC css 选择器选择了错误的表行
编辑:我在最初发布的表格数据中犯了一个错误。更正内容以粗体显示。
我正在为 Selenium RC 编写 Python。在下面的文档中,我尝试选择包含“United States”和“1”的表格行,但选择器始终选择包含“United States”和“214”的行。我想我知道为什么。看起来 :contains() 与 214 中的“1”匹配并且该行被选中。
这是我的选择器语法:
self.selenium.click("css=table#filltbl tr td:contains(%s) + td:contains(%s)"%(country, area_code))
其中国家==“美国”和地区代码==“1”。似乎相邻的同级组合器被忽略了。
如何使 :contains() 完全匹配“1”?
感谢并抱歉造成混乱。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
. . .
<table class="wrapper" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table id="filltbl" class="tfill" cellspacing="0" cellpadding="0">
<tbody>
<tr class="fill">
<td>United States</td>
<td>214</td>
<td> </td>
</tr>
<tr class="fill">
<td>United States</td>
<td>1</td>
<td> </td>
</tr>
</tbody>
</table>
. . .
Edit: I made a mistake in the table data that I originally posted with. Correction's in bold.
I'm writing Python for Selenium RC. In the document below I'm trying to select the table row that contains "United States" and "1", but the selector is always selecting the row that contains "United States" and "214" instead. I think I know why. Looks like :contains() is matching the "1" in 214 and that row is selected.
This is my selector syntax:
self.selenium.click("css=table#filltbl tr td:contains(%s) + td:contains(%s)"%(country, area_code))
where country == "United States" and area_code == "1". It seems that the adjacent sibling combinator is being ignored.
How can I make :contains() match exactly "1" ?
Thanks and sorry for the confusion.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
. . .
<table class="wrapper" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table id="filltbl" class="tfill" cellspacing="0" cellpadding="0">
<tbody>
<tr class="fill">
<td>United States</td>
<td>214</td>
<td> </td>
</tr>
<tr class="fill">
<td>United States</td>
<td>1</td>
<td> </td>
</tr>
</tbody>
</table>
. . .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看一些示例,它们有助于创建复杂的 css3 定位器
check some examples that can be helpful for creating complex css3 locators