簡體   English   中英

Applitools openBase() 因 com.applitools.eyes.EyesException 而失敗

[英]Applitools openBase() failed with com.applitools.eyes.EyesException

我無法弄清楚為什么這段代碼會失敗,我瀏覽了 Applitools 教程,但無法弄清楚這里發生了什么。

這是拋出的異常:

com.applitools.eyes.EyesException: eyes.openBase() failed

                at com.applitools.eyes.EyesBase.openBase(EyesBase.java:1037)
                at com.applitools.eyes.selenium.SeleniumEyes.open(SeleniumEyes.java:246)
                at com.applitools.eyes.selenium.Eyes.open(Eyes.java:77)
                at com.applitools.eyes.selenium.Eyes.open(Eyes.java:1374)
                at BaseTests.validateWindow(BaseTests.java:49)
                at SearchTests.testSearchByFullTitle(SearchTests.java:11)

這是搜索測試:

import org.junit.Test;

public class SearchTests extends BaseTests {

    @Test
    public void testSearchByFullTitle(){
        String title = "Agile Testing";
        page.search(title);
        validateWindow();
    }
}

驗證窗口方法:

public void validateWindow(){
    eyes.open(driver, "Automation Bookstore", "neka metoda npr: "+
            Thread.currentThread().getStackTrace()[2].getMethodName());
    eyes.checkWindow();
    eyes.close();
}

和拋出異常的類:

protected void openBase() throws EyesException {
    openLogger();
    int retry = 0;
    do {
        try {
            if (isDisabled) {
                logger.verbose("Ignored");
                return;
            }

            sessionEventHandlers.testStarted(getAUTSessionId());

            validateApiKey();
            logOpenBase();
            validateSessionOpen();

            initProviders();

            this.isViewportSizeSet = false;

            sessionEventHandlers.initStarted();

            beforeOpen();

            RectangleSize viewportSize = getViewportSizeForOpen();
            viewportSizeHandler.set(viewportSize);

            try {
                if (viewportSize != null) {
                    ensureRunningSession();
                }
            } catch (Exception e) {
                GeneralUtils.logExceptionStackTrace(logger, e);
                retry++;
                continue;
            }

            this.validationId = -1;

            isOpen = true;
            afterOpen();
            return;
        } catch (EyesException e) {
            logger.log(e.getMessage());
            logger.getLogHandler().close();
            throw e;
        }


    } while (MAX_ITERATION > retry);

    throw new EyesException("eyes.openBase() failed");
}

經過一些調試,我發現我的 API 密鑰中有一個錯字。 修復后,按預期工作。

在我的例子中,同樣的問題是由使用null作為testName參數的值引起的。

我從一開始就不明白,因為我依賴於 javadoc 的open函數:

    /**
     * Starts a test.
     *
     * @param driver   The web driver that controls the browser hosting                 the application under test.
     * @param appName  The name of the application under test.
     * @param testName The test name.                 (i.e., the visible part of the document's body) or                 {@code null} to use the current window's viewport.
     * @return A wrapped WebDriver which enables SeleniumEyes trigger recording and frame handling.
     */
    public WebDriver open(WebDriver driver, String appName, String testName) {
        RectangleSize viewportSize = SeleniumEyes.getViewportSize(driver);
        this.configuration.setAppName(appName);
        this.configuration.setTestName(testName);
        this.configuration.setViewportSize(viewportSize);
        return open(driver);
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM