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
Html 使用Selenium访问内部文本锚定标记_Html_Selenium_Selenium Rc - Fatal编程技术网

Html 使用Selenium访问内部文本锚定标记

Html 使用Selenium访问内部文本锚定标记,html,selenium,selenium-rc,Html,Selenium,Selenium Rc,我试图迭代一个表并通过XPath访问值, 例如: /html/body/div[2]/form/div/table/tbody/tr/td[2]/table[4]/tbody/tr[3]/td[10]/span/a /html/body/div[2]/form/div/table/tbody/tr/td[2]/table[4]/tbody/tr[4]/td[10]/span/a /html/body/div[2]/form/div/table/tbody/tr/td[2]/table[4]/tb

我试图迭代一个表并通过XPath访问值, 例如:

/html/body/div[2]/form/div/table/tbody/tr/td[2]/table[4]/tbody/tr[3]/td[10]/span/a
/html/body/div[2]/form/div/table/tbody/tr/td[2]/table[4]/tbody/tr[4]/td[10]/span/a
/html/body/div[2]/form/div/table/tbody/tr/td[2]/table[4]/tbody/tr[5]/td[10]/span/a
/html/body/div[2]/form/div/table/tbody/tr/td[2]/table[4]/tbody/tr[...]/td[10]/span/a
锚定标记的内部html中包含的值:

    <td>
     <span id="TUFLMTU1MA%3D%3D">
      <a onclick="return false" target="_top" href="">VALUE I WANT</a>
     </span>
    </td>
我尝试了Xpath语句,除了使用超链接外,它通常都能正常工作。我不能使用id属性,因为它们都是动态的。我试图获取的文本是我想要的上面的值。另外,我希望整个表中的值都发生变化,所以我不能仅仅基于这个值,因为它不是每次都相同的值


我使用的是Selenium RC,而不是web驱动程序。

将xpath放入“for”循环中,并在有元素时重复多次

for(int x = 1; x < your_neumber_of_elements; x++) {
  WebElement e = driver.findElement(By.xpath("//table/tbody/tr/td[2]/table[4]/tbody/tr[" + x + "]/td[10]/span/a"));
  Syste.out.println(e.getText());
}

我只是想知道:你为什么要使用一种已经被弃用了好几年的技术?