Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium xpath轴的Css等价物_Selenium_Selenium Webdriver - Fatal编程技术网

Selenium xpath轴的Css等价物

Selenium xpath轴的Css等价物,selenium,selenium-webdriver,Selenium,Selenium Webdriver,有人能告诉我以下xpath轴的css等价物吗 1. ancestor 2. descendant 3. following 4. following-sibling 5. preceding 6. preceding-sibling 因此,我可以为XPath提供css替代方案,如下所示: 1. //table/descendant::td/input 2. //td/following-sibling::td 你可以参考了解选择器,我不相信CSS中有与之完全匹配的选项。如果您

有人能告诉我以下xpath轴的css等价物吗

 1. ancestor
 2. descendant
 3. following
 4. following-sibling
 5. preceding
 6. preceding-sibling
因此,我可以为XPath提供css替代方案,如下所示:

 1. //table/descendant::td/input
 2. //td/following-sibling::td

你可以参考了解选择器,我不相信CSS中有与之完全匹配的选项。如果您想在DOM中进行如此多的移动,XPath可能是您唯一的方法。例如,CSS选择器中没有父元素的概念。谢谢Amith和Arran!最后,我可以得出的结论是“在某些情况下,xpath是定位元素的唯一方法”,如果您可以向尝试选择的元素添加特定的类,那么CSS选择器可以非常好地工作。