UFT / QTP-在两个WebElement之间查找WebElement

时间:2019-06-11 12:29:48

标签: selenium xpath automation qtp uft14

我有什么?

    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

但是我只是语法不正确。

0 个答案:

没有答案