java - 我在网页中有一个表格,其中有一个如图所示的界面。通过匹配接口(interface)名称,我需要单击箭头-LMLPHP我有一个网页,其中有一个通过与我需要单击箭头的接口代码匹配的表。

driver.findElement(By.xpath("//td/descendant::span[contains(text(),'STR_PGW.RETURN')]/parent::tr/td/descendant::button[@class='kbnDocTableOpen__button']")).click();

最佳答案

公共无效负载(WebDriver驱动程序,BaseTest基本测试)抛出异常{

    List<WebElement> PayloadXml = driver.findElements(By.xpath("//tr[@ng-repeat='field in fields']"));
    System.out.println("payload");

    for (WebElement P : PayloadXml)
        System.out.println(P.getText());

    List<WebElement> PayloadXmlvalues = driver.findElements(By.xpath("//div[@class='kbnDocViewer__value']"));
    String payload = "<CreditReturnRequest>";
    for (WebElement V : PayloadXmlvalues)
        System.out.println(V.getText());

    for (int i = 0; i <= PayloadXmlvalues.size(); i++) {
        // System.out.println("Content text is : " + PayloadXml.get(i).getText());
        // match the content here in the if loop
        if (PayloadXml.get(i).getText().contains(payload)) {

            String xmlvalues = PayloadXmlvalues.get(i).getText();
            String xmlOutputFile = "data.xml";

10-04 10:20