java—如何从另一个测试方法调用测试方法

8xiog9wr  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(301)

**在这里我从method4调用method1,我希望所有的方法都应该一个接一个地执行,你能建议什么是最好的解决方案吗。

在执行之后,我只能查看method1的结果,但我的期望是看到所有要执行的测试用例。
测试等级

@Test(priority = 1, retryAnalyzer = com.brcc.tool.RetryFailedTestCases.RetryTestCases.class)
     public void method1() throws Exception {
    wait = new WebDriverWait(driver, 10);
    sftpCon.writeIntoExcel("Result", "searchClient", "Failed -  Invalid Client");
    WebElement clientRadio = wait.until(

    ExpectedConditions.visibilityOfElementLocated
      (By.xpath(prop.getProperty("clientRadioButtonValue"))));
    String clientname = sftpCon.clientProduct("Client Type",j);
    WebElement clickradioButton = wait.until(
            ExpectedConditions.visibilityOfElementLocated
    (By.cssSelector(prop.getProperty("clientRadioButton"))));
    clickradioButton.click();

    sftpCon.writeIntoExcel("Result", "searchClient", "Passed");
}
            @Test(priority = 2, retryAnalyzer = 
   com.brcc.tool.RetryFailedTestCases.RetryTestCases.class)
    public void method2() throws Exception {
        wait = new WebDriverWait(driver, 10);

        String getDeliveryChannel = sftpCon.deliveryChannel("Search Criteria", 0);
        sftpCon.writeIntoExcel("Result", "deliveryChannel", "failed");
        WebElement deliveryChannelDropDown = wait
                .until(ExpectedConditions.elementToBeClickable
      (By.xpath(prop.getProperty("deliveryChannel"))));
        select = new Select(deliveryChannelDropDown);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        List<WebElement> listSelectApp = select.getOptions();
        for (int i = 0; i < listSelectApp.size(); i++) {
            String app = listSelectApp.get(i).getText();
            if (getDeliveryChannel.contains(app)) {
                listSelectApp.get(i).click();
            }
        }
        sftpCon.writeIntoExcel("Result", "deliveryChannel", "Passed");

    }

    @Test(priority = 3, retryAnalyzer = com.brcc.tool.RetryFailedTestCases.RetryTestCases.class)
    public void method3s() throws Exception {
        wait = new WebDriverWait(driver, 10);
        sftpCon.writeIntoExcel("Result", "printStatus", "failed");
        String printStatus = sftpCon.deliveryChannel("Search Criteria", 1);
        Assert.assertTrue(true, "you have selected " + printStatus);
        WebElement printStatusDropDown = wait
                .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(prop.getProperty("printStatus"))));
        select = new Select(printStatusDropDown);
        List<WebElement> listSelectApp = select.getOptions();
        for (int i = 0; i < listSelectApp.size(); i++) {
            String app = listSelectApp.get(i).getText();
            if (printStatus.contains(app)) {
                listSelectApp.get(i).click();
            }
        }
        sftpCon.writeIntoExcel("Result", "printStatus", "Passed");
    }
         @Test(priority = 4,retryAnalyzer = 
       com.brcc.tool.RetryFailedTestCases.RetryTestCases.class)
          public void method4() throws Exception {
        //getRmApp
        wait = new WebDriverWait(driver, 10);
        WebElement clearClient = wait.until(
                ExpectedConditions.visibilityOfElementLocated
        (By.xpath(prop.getProperty("clearSelectedClient"))));
        clearClient.click();
        WebElement clearsearchContent = wait.until(
                ExpectedConditions.visibilityOfElementLocated
         (By.xpath(prop.getProperty("contenTypeAndDocType"))));
        clearsearchContent.clear();
           j=j+1;
        String getclientProduct = sftpCon.clientProduct("Client Type",j);
        System.out.println("getclientProduct----------"+getclientProduct);
        System.out.println("sftpCon.clientProduct(\"Client Type\",j) 
        ======="+sftpCon.clientProduct("Client Type",j));
        if(!getclientProduct.isEmpty())
        {

            //getRmApp(j);
            sftpCon.writeIntoExcel("Result", "login", "Passed");
            sftpCon.clientProduct("Client Type",j);
            String getClient = sftpCon.clientProduct("Client Type",j);
            System.out.println("getClient "+getClient);
            WebElement searchContent = wait.until(
                    ExpectedConditions.visibilityOfElementLocated(By.xpath(prop.getProperty("contenTypeAndDocType"))));
            searchContent.sendKeys(sftpCon.clientProduct("Client Type",j));
            sftpCon.writeIntoExcel("Result", "startRmApp", "Passed");
            method1();

        }
        else
        {
            System.out.println("All client is executed Please Stop your Work");
        }

        System.out.println("Success");
    }

如上所述,test类包含需要有序执行的方法。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题