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_Selenium_Xpath_Selenium Webdriver - Fatal编程技术网

Selenium 如何使用变量编写xpath

Selenium 如何使用变量编写xpath,selenium,xpath,selenium-webdriver,Selenium,Xpath,Selenium Webdriver,我有一个xpath=/*[@id='00QE000000gQ9fv_ACTION_COLUMN']/a[2]/span 在此xpath中,00QE0000000GQ9FV是动态的,\u ACTION\u列保持不变。 我将00QE000000gQ9fv存储在字符串变量中,作为recordId String recordId=00QE000000gQ9fv 现在我想要一个包含recordId变量的xpath。您的xpath将是-/*[contains(@id,“\u ACTION\u COLUMN'

我有一个
xpath=/*[@id='00QE000000gQ9fv_ACTION_COLUMN']/a[2]/span
在此xpath中,
00QE0000000GQ9FV
是动态的,
\u ACTION\u列
保持不变。 我将
00QE000000gQ9fv
存储在字符串变量中,作为
recordId
String recordId=00QE000000gQ9fv

现在我想要一个包含
recordId
变量的xpath。

您的xpath将是-
/*[contains(@id,“\u ACTION\u COLUMN')]/a[2]/span

确保
\u ACTION\u列
是唯一的,或者是html中的第一个元素,以便抓住正确的元素

根据您的评论编辑1

试试这个:
/*[contains(@id,“+recordId+”)]/a[2]/span


/*[@id=”+recordId+“\u ACTION\u COLUMN']/a[2]/span

请发布html。我无法理解您试图实现的目标。Thanx Ramesh,但问题是我需要在这个xpath中使用recordId变量,因为我需要根据redordId删除记录