selenium Katalon Studio -点击元素后-它通过了,但什么也没发生

ymdaylpp  于 2023-01-20  发布在  其他
关注(0)|答案(1)|浏览(168)

当我点击按钮时(手动点击后,新的弹出窗口将打开),但在Katalon Studio中,当我点击时,它通过了,但什么也没发生,窗口不会打开)
代码试验:

WebUI.click(findTestObject('Object Repository/POkus3/Page_Dashboard - altFINS/vaadin-tab_Overview'))
WebUI.click(findTestObject('Object Repository/POkus3/Page_Dashboard - altFINS/vaadin-menu-bar_Free Registered User_userMe_6d88ae'))
WebUI.click(findTestObject('Object Repository/POkus3/Page_Dashboard - altFINS/vaadin-context-menu-item_Accounts'))
WebUI.waitForElementClickable(findTestObject('Pokus2/Page_Accounts - altFINS/Sergej'), 10)
WebUI.doubleClick(findTestObject('Pokus2/Page_Accounts - altFINS/Sergej'))
stszievb

stszievb1#

您是否尝试过以下方法:
创建一些自定义Keyword类,定义为:

public final class GeneralWebUIUtils { 

    public static int GetNumberOfWindows() { 
        return DriverFactory.getWebDriver()
            .getWindowHandles()
            .size();
    }

    public static boolean WaitForCondition(Closure<Boolean> onCheckCondition, int timeOut, Closure<String> onErrorMessage, FailureHandling failureHandling = FailureHandling.STOP_ON_FAILURE) { 
        boolean isConditionSatisfied = false;
        final long startTime = System.currentTimeMillis();

        while((!isConditionSatisfied) && (System.currentTimeMillis() <= startTime + timeOut * 1000) { 
            isConditionSatisfied = onCheckCondition();
        }

        if ((!isConditionSatisfied) && failureHandling.equals(FailureHandling.STOP_ON_FAILURE))
            throw new StepFailedException(onErrorMessage(this.GetElapsedTime(startTime)));

        return isConditionSatisfied;

    }

    public static boolean WaitForWindowOpenChange(int timeOut, FailureHandling failureHandling = FailureHandling.STOP_ON_FAILURE) { 
        final int initNumberOfWindows = this.GetNumberOfWindows();

        return this.WaitForCondition({
                return this.GetNumberOfWindows() != initNumberOfWindows;
            }, 
            timeOut,
            { double elapsedTime ->
                return "Number of open windows/tabs has NOT changed after ${elapsedTime} seconds";
            },
            failureHandling,
        );
    }

    public static double GetElapsedTime(long startTimeMillis) { 
        return (System.currentTimeMillis() - startTimeMillis) / 1000.0;
    }
}

然后,在你的测试用例中,像这样调用它:

WebUI.click(findTestObject('Pokus2/Page_Accounts - altFINS/Sergej'));
GeneralWebUIUtils.WaitForWindowOpenChange(15);

这将解决您的问题,如果不是仅仅使您的测试用例失败的话。
请查看代码,如果有任何问题请告诉我!

更新:我刚刚从你的评论中看到,你试图与之交互的输入按钮存在于一些影子根中。

在这种情况下,您需要create Test Object for the shadow root element, and then make the Test Object for it a child Test Object of that

相关问题