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
soActiveCell.Offset(0,0)相同。Value
是冗余的。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
soActiveCell.Offset(0,0)相同。Value
是冗余的。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