Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.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
Excel 工作表中cellvalue中的FindElementByXPath_Excel_Vba_Selenium - Fatal编程技术网

Excel 工作表中cellvalue中的FindElementByXPath

Excel 工作表中cellvalue中的FindElementByXPath,excel,vba,selenium,Excel,Vba,Selenium,在findelementbypath中,是否有方法将单元格的值用作路径? 我在Excel和Selenium中使用VBA 例如: Active cell "//*[@id="content"]/div[1]/div" testPath=ActiveCell.Offset(0, 0).value ActiveCell.Offset(0, 1).value = driver.FindElementByXPath("testpath")

findelementbypath
中,是否有方法将单元格的值用作路径? 我在Excel和Selenium中使用VBA

例如:

Active cell "//*[@id="content"]/div[1]/div"

testPath=ActiveCell.Offset(0, 0).value

ActiveCell.Offset(0, 1).value = driver.FindElementByXPath("testpath")
(双引号)双引号
  • 使用
    选项Explicit
    学习自己解决错误
  • ActiveCell.Value
    ActiveCell.Offset(0,0)相同。Value
    so
    。Offset(0,0)
    是冗余的
  • TestPath
    是一个变量,因此您不能使用双引号引用它
  • 要将给定字符串写入变量,必须使用双引号(
    “”
    ),如第二个过程所示。自己测试一下
代码

Option Explicit

Sub ActiveCellTestPath()
    
    ' ...
    
    Dim TestPath As String
    TestPath = ActiveCell.Value
    ActiveCell.Offset(0, 1).Value = driver.FindElementByXPath(TestPath)

    ' ...

End Sub

Sub DoubleQuotes()
    Dim TestPath As String
    TestPath = "//*[@id=""content""]/div[1]/div"
    Debug.Print TestPath
End Sub
(双引号)双引号
  • 使用
    选项Explicit
    学习自己解决错误
  • ActiveCell.Value
    ActiveCell.Offset(0,0)相同。Value
    so
    。Offset(0,0)
    是冗余的
  • TestPath
    是一个变量,因此您不能使用双引号引用它
  • 要将给定字符串写入变量,必须使用双引号(
    “”
    ),如第二个过程所示。自己测试一下
代码

Option Explicit

Sub ActiveCellTestPath()
    
    ' ...
    
    Dim TestPath As String
    TestPath = ActiveCell.Value
    ActiveCell.Offset(0, 1).Value = driver.FindElementByXPath(TestPath)

    ' ...

End Sub

Sub DoubleQuotes()
    Dim TestPath As String
    TestPath = "//*[@id=""content""]/div[1]/div"
    Debug.Print TestPath
End Sub