Bitbar Cloud Appium服务器端JavaScript的测试包内容

西蒙·汉布雷

使用Java语言作为语言时,有人知道用于服务器端测试运行的zip文件的内容是什么吗?我已经看了github页面(GitHub上的bitbar-samples存储库上的python和ruby示例,但是Javascript没有任何内容,并且在文档中也是如此-仅Java和python。但是没有Java语言。

马韦里克斯

从文档:

测试所需的所有文件都需要以zip包的形式上传到云中。该软件包必须包含测试文件,数据文件,并且需要具有Shell脚本才能在软件包的根级别启动测试执行。

和:

为了使云端执行正常工作,重要的是使测试套件zip配备正确的文件。在这里,我们将浏览文件以及测试zip的正确构成。最重要的是run-tests.sh文件,它负责在云中启动测试执行并安装需求。

因此,从理论上讲,您只能在ZIP包中包含run-tests.sh文件。并且由于这是一个简单的bash脚本,因此您可以自由执行此脚本。查看Python和Ruby示例,这就是我的ZIP结构的样子:

.
├── package.json
├── package-lock.json
├── run-tests.sh
├── test
│   └── specs
│       └── main.js
└── wdio.conf.js

我使用过Webdriver.io Testrunner-这就是为什么我有wdio.conf.jsand的原因test/specs/main.js

这是我的run-tests.sh样子:

#!/usr/bin/env bash

echo "Preparing..."

# Make sure there's no pre-existing `screenshots` file blocking symbolic link creation
rm -rf screenshots

# Recreate screenshots dir
mkdir screenshots

echo "Extracting tests.zip..."
unzip tests.zip

echo "Installing dependencies..."
npm install

echo "Running tests..."
./node_modules/.bin/wdio wdio.conf.js

我的main.js(我bitbar-sample-app.apk从头开始使用和测试方法):

describe('Bitbar Sample App', () => {
    it('Should radio button should be visible ', async () => {
        let el = await $('//android.widget.RadioButton[@text="Buy 101 devices"]');
        let visible = await el.isDisplayed();
        visible.should.be.true;
    });

    it('Should show failure page', async () => {
        let el;

        console.log("view1: Clicking button - 'Buy 101 devices'");
        el = await $('//android.widget.RadioButton[@text="Buy 101 devices"]');
        el.click();

        console.log("view1: Typing in textfield[0]: Bitbar user");
        el = await $('//android.widget.EditText[@resource-id="com.bitbar.testdroid:id/editText1"]');
        el.setValue('Bitbar user');

        driver.hideKeyboard();
        console.log("view1: Taking screenshot screenshot1.png");
        await takeScreenshot('screenshot1');

        console.log("view1: Clicking button Answer");
        el = await $('//android.widget.Button[@text="Answer"]');
        el.click();

        console.log("view2: Taking screenshot screenshot2.png");
        await takeScreenshot('screenshot2');

        el = await $('//android.widget.TextView[@text="Wrong Answer!"]');
        let txt = await el.getText();
        txt.should.be.equal('Wrong Answer!');
    });

});

wdio.conf.js(看看before钩子):

const path = require('path');

exports.config = {
    runner: 'local',

    framework: 'mocha',
    mochaOpts: {
        ui: 'bdd',
        timeout: 60000
    },

    logLevel: 'silent',
    deprecationWarnings: true,

    bail: 0,
    waitforTimeout: 10000,
    connectionRetryTimeout: 90000,
    connectionRetryCount: 3,

    reporters: [
        'spec',
        [
            'junit', {
                outputDir: './',
                outputFileFormat: () => {
                    return 'TEST-all.xml';
                }
            }
        ]
    ],

    host: '127.0.0.1',
    port: 4723,
    path:  '/wd/hub',

    services: ['appium'],
    appium: {
        command: 'appium',
        logPath : './',
    },

    specs: [
        './test/specs/**/*.js'
    ],

    capabilities: [{
        platformName: 'Android',
        maxInstances: 1,

        'appium:deviceName': 'Android device',
        'appium:automationName': 'UiAutomator2',
        'appium:app': path.resolve('application.apk'),
        'appium:appActivity': '.BitbarSampleApplicationActivity',
        'appium:appPackage': 'com.bitbar.testdroid',
        'appium:newCommandTimeout': 240
    }],

    before: function() {
        const chai = require('chai');
        global.expect = chai.expect;
        chai.should();

        const fs = require('fs');

        global.takeScreenshot = async (fileName) => {
            let screenshot = await driver.takeScreenshot();
            screenshot = screenshot.replace(/^data:image\/png;base64,/, "")
            let filePath = path.resolve(`./screenshots/${fileName}.png`);
            fs.writeFileSync(filePath, screenshot, 'base64');
        };

    }
}

最后但并非最不重要的package.json

{
  "name": "appium-server-side-example",
  "version": "1.0.0",
  "description": "Bitbar Cloud Appium Server Side Test Example",
  "author": "Marek Sierociński <[email protected]>",
  "license": "ISC",
  "dependencies": {
    "@wdio/appium-service": "^5.16.5",
    "@wdio/cli": "^5.16.7",
    "@wdio/junit-reporter": "^5.15.5",
    "@wdio/local-runner": "^5.16.7",
    "@wdio/mocha-framework": "^5.16.5",
    "@wdio/spec-reporter": "^5.16.5",
    "@wdio/sync": "^5.16.5",
    "chai": "^4.2.0"
  }
}

如您所见,我曾经chai(因为我想使用BDD方法)和junit-reporter(因为Bitbar开发者是Java怪胎,并且您可以从样本中猜测Cloud正在读取JUnit文件以读取测试方法)。

它为我工作:

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

我有机会做任何事情之前,使用BitBar云进行的Appium会话超时

来自分类Dev

Firebase Cloud Messaging和C#服务器端代码

来自分类Dev

GCM(Google Cloud Messaging)的服务器端错误“ invalidRegistration”

来自分类Dev

如何在Amazon Cloud Drive上提取文件服务器端?

来自分类Dev

“服务器端扇出”是否可以使用 Cloud Functions for Firebase 进行处理?

来自分类Dev

如何测试服务器端debugOnly包

来自分类Dev

如何使用服务器上的Node从客户端JavaScript上传到Google Cloud Storage?

来自分类Dev

Spring Cloud配置服务器.properties内容协商失败

来自分类Dev

如何找到com.bitbar.recorder.extensions.ExtSolo的jar?

来自分类Dev

CQ-编写服务器端JUnit测试

来自分类Dev

DataTables服务器端处理添加html内容选择标记不会触发javascript

来自分类Dev

服务器端javascript / java-javascript通信

来自分类Dev

服务器端javascript / java-javascript通讯

来自分类Dev

Spring Cloud Eureka客户端到多个Eureka服务器

来自分类Dev

Spring Cloud Config客户端未从配置服务器加载配置

来自分类Dev

如何在Spring Cloud中从客户端配置多个Eureka服务器

来自分类Dev

Spring Cloud配置客户端未从配置服务器中选择值

来自分类Dev

Spring Cloud Config:客户端不会尝试连接到配置服务器

来自分类Dev

Spring Cloud处理多个并发客户端和服务器

来自分类Dev

在客户端中修改Spring Cloud配置服务器

来自分类Dev

如何在 Google Cloud Platform 上部署 GRPC 服务器和客户端?

来自分类Dev

Google Cloud SQL:在“读取初始通信数据包”时失去与MySQL服务器的连接

来自分类Dev

Google Cloud SQL:在“读取初始通信数据包”时失去与MySQL服务器的连接

来自分类Dev

如何更新Google Cloud Platform旧版GAE和GCF元数据服务器端点

来自分类Dev

尝试从JavaScript访问服务器端变量

来自分类Dev

从服务器端调用Javascript函数

来自分类Dev

Javascript最佳做法-使用服务器端值

来自分类Dev

C#中的服务器端Javascript警报

来自分类Dev

服务器端JavaScript代码注入攻击

Related 相关文章

  1. 1

    我有机会做任何事情之前,使用BitBar云进行的Appium会话超时

  2. 2

    Firebase Cloud Messaging和C#服务器端代码

  3. 3

    GCM(Google Cloud Messaging)的服务器端错误“ invalidRegistration”

  4. 4

    如何在Amazon Cloud Drive上提取文件服务器端?

  5. 5

    “服务器端扇出”是否可以使用 Cloud Functions for Firebase 进行处理?

  6. 6

    如何测试服务器端debugOnly包

  7. 7

    如何使用服务器上的Node从客户端JavaScript上传到Google Cloud Storage?

  8. 8

    Spring Cloud配置服务器.properties内容协商失败

  9. 9

    如何找到com.bitbar.recorder.extensions.ExtSolo的jar?

  10. 10

    CQ-编写服务器端JUnit测试

  11. 11

    DataTables服务器端处理添加html内容选择标记不会触发javascript

  12. 12

    服务器端javascript / java-javascript通信

  13. 13

    服务器端javascript / java-javascript通讯

  14. 14

    Spring Cloud Eureka客户端到多个Eureka服务器

  15. 15

    Spring Cloud Config客户端未从配置服务器加载配置

  16. 16

    如何在Spring Cloud中从客户端配置多个Eureka服务器

  17. 17

    Spring Cloud配置客户端未从配置服务器中选择值

  18. 18

    Spring Cloud Config:客户端不会尝试连接到配置服务器

  19. 19

    Spring Cloud处理多个并发客户端和服务器

  20. 20

    在客户端中修改Spring Cloud配置服务器

  21. 21

    如何在 Google Cloud Platform 上部署 GRPC 服务器和客户端?

  22. 22

    Google Cloud SQL:在“读取初始通信数据包”时失去与MySQL服务器的连接

  23. 23

    Google Cloud SQL:在“读取初始通信数据包”时失去与MySQL服务器的连接

  24. 24

    如何更新Google Cloud Platform旧版GAE和GCF元数据服务器端点

  25. 25

    尝试从JavaScript访问服务器端变量

  26. 26

    从服务器端调用Javascript函数

  27. 27

    Javascript最佳做法-使用服务器端值

  28. 28

    C#中的服务器端Javascript警报

  29. 29

    服务器端JavaScript代码注入攻击

热门标签

归档