Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
如何使用标题访问表';s<;a>;xpath/selenium中的标记_Selenium_Xpath - Fatal编程技术网

如何使用标题访问表';s<;a>;xpath/selenium中的标记

如何使用标题访问表';s<;a>;xpath/selenium中的标记,selenium,xpath,Selenium,Xpath,我试图通过以下部分访问html表(通过selenium/python): 这就是你要做的 //table[caption/a[@name='Student']]/tbody/tr/td[1]/a 虽然这是一个有效的XPath,但它将返回一个文本节点而不是WebElement,因此它不是有效的定位器。要使其成为有效的定位器,请删除其末尾的text()部分。而不是使用。\td[1]\..,而是使用class=“name”等//表[caption/a[@name='Student']/tbody/

我试图通过以下部分访问html表(通过selenium/python):


这就是你要做的

//table[caption/a[@name='Student']]/tbody/tr/td[1]/a

虽然这是一个有效的XPath,但它将返回一个文本节点而不是WebElement,因此它不是有效的定位器。要使其成为有效的定位器,请删除其末尾的
text()
部分。而不是使用
。\td[1]\..
,而是使用class=“name”等
//表[caption/a[@name='Student']/tbody/tr/td[@class='name']/a
来查找正确的td,因此如果
a
标记移动
td
s,定位器不太可能损坏。