在本机Android应用上找不到元素-Appium,W​​ebdriverIO,Mocha和Chai

时间:2018-08-08 15:00:39

标签: android mocha appium

我无法在本地Android应用(AppiumWebdriverIOMochaChai)上找到元素。

不确定为什么无法找到元素并将click()事件应用于该特定元素,以便它自动进入应用程序的下一个屏幕。而且不确定,这实际上意味着什么:

{"status":7,"value":"No element found"}

我也尝试这样做:

client.elementByXPath('xpath val')

但最后一行抛出:

elementByXPath not a function

我的代码:

describe('Testing', function(){
    before(function(){
        this.timeout(50000);
        return client.init();
    });
    describe('Test CALCU addition', function(){
        it('should display list of projects', function(){
            client.click(
                'android=new UiSelector().resourceId(
                    "uk.co.polestar.app:id/firstLineDisplayName")');
        });
    });
});

下面的错误日志:

[HTTP] <-- POST /wd/hub/session 200 41752 ms - 1203
[HTTP] 
[HTTP] --> POST /wd/hub/session/975b8acc-151e-482c-9a66-60446e1023e0/element
[HTTP] {"using":"-android uiautomator","value":"new UiSelector().resourceId(\"uk.co.polestar.app:id/firstLineDisplayName\")"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().resourceId(\"uk.co.polestar.app:id/firstLineDisplayName\")","975b8acc-151e-482c-9a66-60446e1023e0"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().resourceId(\"uk.co.polestar.app:id/firstLineDisplayName\")","context":"","multiple":false}}
[HTTP] <-- POST /wd/hub/session/975b8acc-151e-482c-9a66-60446e1023e0/element - - ms - -
[HTTP] 
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().resourceId(\"uk.co.polestar.app:id/firstLineDisplayName\")","context":"","multiple":false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().resourceId("uk.co.polestar.app:id/firstLineDisplayName")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().resourceId("uk.co.polestar.app:id/firstLineDisplayName")
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "uk.co.polestar.app:id/firstLineDisplayName"
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[RESOURCE_ID=uk.co.polestar.app:id/firstLineDisplayName]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().resourceId("uk.co.polestar.app:id/firstLineDisplayName")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().resourceId("uk.co.polestar.app:id/firstLineDisplayName")
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "uk.co.polestar.app:id/firstLineDisplayName"
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[RESOURCE_ID=uk.co.polestar.app:id/firstLineDisplayName]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}

但是结果是通过:

automatedtesting@automatedtesting:~/CALCU$ mocha webdriverio-calcu.js

1个通过(43s)

0 个答案:

没有答案