Appium 无法访问应用程序Node.Js中的getText()方法

Appium 无法访问应用程序Node.Js中的getText()方法,appium,webdriver-io,appium-android,android-uiautomator,Appium,Webdriver Io,Appium Android,Android Uiautomator,我正在尝试使用Appium测试android应用程序。我想读取textview的值,但无法读取。I getgetText()不是函数错误。 以下是我的功能和代码: const webdriverio = require('webdriverio'); const assert = require('chai').assert; const options = { capabilities: { platformName: 'Android', au

我正在尝试使用Appium测试android应用程序。我想读取textview的值,但无法读取。I getgetText()不是函数错误。 以下是我的功能和代码:

 const webdriverio = require('webdriverio');
 const assert = require('chai').assert;

 const options = {
    capabilities: {
        platformName: 'Android',
        automationName: 'UiAutomator2',
        deviceName: 'Android',
        app: "some.apk",
        appWaitActivity: 'com.example.HomeActivity',
        autoGrantPermissions: true,
        autoAcceptAlerts: true,
        fullReset: true,
      },
       host: '0.0.0.0',
       port: 4723
   };


 describe('Start Test', function() {

     let client;
     before(async function() {
         client = await webdriverio.remote(options);
     });

     it('get text in textview', async function() {
          element = await client.findElement('id', "com.example:id/screenMsg"); // element is the textView
          assert.isNotNull(element);

          console.log(element); 

       /* In the console, I get something like this
          { 'element-6066-11e4-a52e-4f735466cecf': '96ec3f2a-7378-4920-a59f- c43a62bc7a44',
          ELEMENT: '96ec3f2a-7378-4920-a59f-c43a62bc7a44' }
          It means the textView is identified.
        */

         value = await element.getText(); // TypeError: element.getText() is not a function.

         console.log(value);
    });


});
只需调用
text()
方法即可检索值

const value = await element.text();
只需调用
text()
方法即可检索值

const value = await element.text();

WebdriverIO选项中的属性是
hostname
,而不是“
host
”。
请参阅。

WebdriverIO选项中的属性是
hostname
,而不是“
host
”。
请参阅。

显示整个测试我添加了整个代码。谢谢。我应该添加哪些功能来访问Appium的方法?最后,我可以使用getElementText()获取文本。关于更多细节,showthealtesti已经添加了整个代码。谢谢。我应该添加哪些功能来访问Appium的方法?最后,我可以使用getElementText()获取文本。欲了解更多详情,