Javascript 通过Selenium VBA executescript查找XPath

Javascript 通过Selenium VBA executescript查找XPath,javascript,vba,selenium,xpath,selenium-chromedriver,Javascript,Vba,Selenium,Xpath,Selenium Chromedriver,我正在尝试使用VBA和Selenium,通过ChromeWebDriver,使用反向XPath查找网页中某些文本的选择器路径 说明如下: Set elements = driver.FindElementsByXPath("//*[contains(text(),'Mysearchstring')]") PathConsole = "$x('//*[contains(text(),'Mysearchstring')]')" Set list_xpath =

我正在尝试使用VBA和Selenium,通过ChromeWebDriver,使用反向XPath查找网页中某些文本的选择器路径

说明如下:

Set elements = driver.FindElementsByXPath("//*[contains(text(),'Mysearchstring')]")
PathConsole = "$x('//*[contains(text(),'Mysearchstring')]')"
Set list_xpath = elements.ExecuteScript(PathConsole)
我总是收到执行错误17。在本例中,在参数列表后提到“missing”。根据我尝试的引号键入变体,我可能会得到“missing}”甚至“$x未定义”

尽管抛出错误并停止,但在VBA调试器的监视列表中,xpath的计算结果正确,结果在变量中显示正确。。。。有没有建议如何正确使用此选项,或者如何选择xpath路径或css选择器


第1页。-我知道$x()本身不是javascript,但它似乎正在努力找出结果和错误

抱歉,但我无法进一步帮助您。