我有什么?
Set WebParent = Browser("openurl:= .*myPage.*").Page("url:= .*myPage.*")
i = 2
x = 2
sValueType = "Statements"
headingOne = "xpath:=//H1[text()='" & sValueDocumentType & "']"
headingTwoLocation = headingOne & "/following::H2[" & i & "]"
paragraphLocation = headingTwoLocation & "/following::P[" & x & "]"
WebParent.WebElement(paragraphLocation).Highlight
这太好了,但是不幸的是,这就是发生的情况。
当我们有H2[2]/following::P[2]
时,基本上就转到H2[3]/following::P[1]
。
所以我想做的是这样的:
WebParent.WebElement("xpath:=//H1[text()='Statements']/following::H2[" & i & "]/following::P[" & x & "] and /preceding::H2[" & i + 1 & "]").Highlight
但是我只是语法不正确。