【问题标题】:Using node appium-xcuitest-driver to test ios app使用 node appium-xcuitest-driver 测试 ios app
【发布时间】:2018-09-07 17:57:00
【问题描述】:
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??
    })

上面的代码打开一个 iOS 模拟器,下载我的应用程序,然后打开它。如何找到一个元素并点击它?

如果我这样做 driver.findElement(By.xpath("//whatever-xpath")) 它告诉我 By 没有定义。但是By 不包含在driver 中。我查看了 appium 文档,但 API 指南仍然是 TODO >: |

我需要导入另一个模块来帮助解决这个问题吗?

在大量谷歌搜索之后,我也找不到任何有用的代码示例。

【问题讨论】:

    标签: ios node.js react-native appium functional-testing


    【解决方案1】:

    如果你想使用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>)
    

    还有一点:用于appium-xcuitest-driver repo中的功能测试

    在运行测试之前启动appium服务很重要:

    • 安装appium:npm install -g appium
    • 用简单的命令appium启动服务

    【讨论】:

    • 感谢您的回复!我怎么知道我应该指向哪个服务器?使用appium-xcuitest-driver 我没有指定一个。我的回复是{ Error: connect ECONNREFUSED 127.0.0.1:4723 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 4723 }
    • 你需要安装appium:npm install -g appium然后用简单的命令appium启动服务器
    • 我爱你。我的意思是,以最不奇怪的方式。
    猜你喜欢
    • 2018-11-11
    • 2019-01-19
    • 2020-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-07
    • 2022-01-20
    • 2019-03-28
    相关资源
    最近更新 更多