简体   繁体   English

使用节点appium-xcuitest-driver测试ios应用

[英]Using node appium-xcuitest-driver to test ios app

const { XCUITestDriver } = require('appium-xcuitest-driver');

const automationConfig = {
    platformName: 'iOS',
    platformVersion: '11.2',
    deviceName: 'iPhone 7',
    app: __dirname + '/cameo.app',
    bundleId: 'com.app.myapp',
};

const driver = new XCUITestDriver();

driver.createSession(automationConfig)
    .then(() => {
        //WHAT DO I DO NOW??
    })

The above code opens an iOS simulator, downloads my app, and opens it. 上面的代码打开一个iOS模拟器,下载我的应用程序,然后将其打开。 How do I find an element and click on it? 如何找到一个元素并单击它?

If I do driver.findElement(By.xpath("//whatever-xpath")) it tells me that By is not defined. 如果我做driver.findElement(By.xpath("//whatever-xpath"))它告诉我By未定义。 But By is not included in driver . 但是By不包含在driver I looked through the appium docs, but the API guide is still a TODO in there >: | 我浏览了appium文档,但API指南仍然是TODO>:|

Do I need to import another module to help with this? 我是否需要导入另一个模块来帮助您?

I haven't been able to find any useful code samples after extensive Googling, either. 在广泛的Google搜索之后,我也找不到任何有用的代码示例。

If you want to use appium-xcuitest-driver for e2e testing, it is better and easier to use wd.js wrapper around it: 如果要使用appium-xcuitest-driver进行e2e测试,最好在其周围使用wd.js包装器:

const wd = require('wd')

desired = {
  platformName: 'iOS',
  platformVersion: '11.1',
  deviceName: 'iPhone SE',
  automationName: 'XCUITest',
  app: <path to app>
}
const server = {
  host: 'localhost',
  port: 4723
}
const driver = wd.promiseChainRemote(server)
await driver.init(desired)
const el1 = await driver.elementByAccessibilityId(<Valid Accessibility Identifier>)
const el2 = await driver.elementsByXPath(<Valid Xpath>)

Another point: it is used for functional tests in appium-xcuitest-driver repo 另一点:它用于appium-xcuitest-driver回购中的功能测试

It is important to start appium service before running tests: 在运行测试之前启动appium服务很重要:

  • install appium: npm install -g appium 安装appium: npm install -g appium
  • Start service with simple command appium 使用简单的命令appium启动服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM