QAF - Web 服务测试未从 XML 获取 Xpath 值

QAF - Webservices testing not fetching Xpath value from XML

我正在尝试使用 QAF 3.0 进行 Web 服务测试 以下是我的测试 BDD。

Scenario: [WS-2]_[222-xml]_Sample XML Webservices
    When I request api "get.mock.xml.menu"
    Then I check api response status code is "200"
    And I check api response status is "OK"
    And I check api response should have xpath '/breakfast_menu'

前三行正在执行,没有任何问题。我在内部调用 QAF WsStep。

Note: Json path verification is working perfectly without any issues.

StepDef:

@QAFTestStep(description = "I check api response should have xpath {xpath}")
public static void iCheckApiResponseShouldHaveXpath(String xpath) {
    WsStep.responseShouldHaveXpath(xpath);
}

在您的例子中 breakfast_menu 是根节点,因此它将被视为上下文(根)并且可以作为 . 访问。您应该能够使用以下 xpath:

.
./food
//food
./food/name
./food[name='Belgian Waffles']
//food[name='Belgian Waffles']
//*[name='Belgian Waffles']