waitForElement Not JSON Response,尝试访问button元素时

问题描述 投票:0回答:1

首先,我对NativeScript和e2e测试很陌生,但我正在尝试在我的演示应用程序上运行一些简单的测试。我完成了安装所有内容的整个设置,并创建了一个e2e(默认)文件夹+文件。

我有这个演示应用程序布局,我基本上有一个按钮:

<ActionBar title="My App" class="action-bar">
</ActionBar>

<GridLayout class="page">
     <StackLayout>
        <Button automationText="testButton" text="Button"></Button>
     </StackLayout>
</GridLayout>

这些是我的测试:

import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
import { assert } from "chai";

describe("sample scenario", () => {
    const defaultWaitTime = 5000;
    let driver: AppiumDriver;

    before(async () => {
        driver = await createDriver();
    });

    after(async () => {
        await driver.quit();
        console.log("Quit driver!");
    });

    afterEach(async function () {
        if (this.currentTest.state === "failed") {
           // await driver.logTestArtifacts(this.currentTest.title);
        }
    });

    it("should find an element by text", async () => {
        const btn = await driver.findElementByText("Button");
        assert.isTrue(btn.exists());
    });

    it("should find an element by automation text", async () => {
         const btn = await driver.findElementByAutomationText("testButton");
         assert.isTrue(btn.exists());
    });
});

我不得不评论这一行,否则,我的测试将无法完成(我必须用ctrl C手动停止它们):

// await driver.logTestArtifacts(this.currentTest.title);

我正在运行它:

$ npm build ios
$ npm run e2e -- --runType sim.iPhone6

我能够运行愚蠢的测试,assertTrue(true),但是当我试图访问一个元素时,按钮出现问题:

    should find an element by text:
 [waitForElementByXPath("//*[@label='Button' or @value='Button' or @hint='Button']",5000)] [elements("xpath","//*[@label='Button' or @value='Button' or @hint='Button']")] Not JSON response
  Error: [elements("xpath","//*[@label='Button' or @value='Button' or @hint='Button']")] Not JSON response
  at exports.newError (node_modules/wd/lib/utils.js:151:13)

和:

 should find an element by automation text:
 [waitForElementByAccessibilityId("testButton",5000)] [elements("accessibility id","testButton")] Not JSON response
  Error: [elements("accessibility id","testButton")] Not JSON response
  at exports.newError (node_modules/wd/lib/utils.js:151:13)

我还试图看看驱动程序是否只是空的或类似的东西,但isIOS和isAndroid工作正常。

我不知道这是否有关于它的事情但是当杀死驱动程序时,这个错误也会弹出:

Error: [quit()] Unexpected data in simpleCallback.

如果有人能提供帮助那就太棒了!谢谢!

appium nativescript e2e-testing
1个回答
0
投票

似乎在{N} Appium Github repo上记录了类似的问题,问题似乎是环境设置,至少在他们的情况下它没有安装carthage

你有没有通过setup process here,确保你有一切到位?

© www.soinside.com 2019 - 2024. All rights reserved.