【发布时间】:2018-08-23 22:56:06
【问题描述】:
我正在为使用 react 构建的移动应用程序自动化测试用例。我正在使用 Appium 框架,我正在使用的客户端是 Webdriver.io,以及用于断言的 Mocha 和 Chai。
到目前为止,我的脚本运行良好,但我遇到了滚动问题。我查看了用于滚动的 Webdriver.io 文档并实现了 touchAction()、touchPerform()、execute()、scrollTo(),但在这种情况下没有任何方法有效。谁能帮我解决这个问题?
这是我正在使用的示例代码
var webdriverio = require("webdriverio");
var expect = require("chai").expect;
var config = require("./helpers/desiredCapabilities").options;
var client = webdriverio.remote(config);
describe("Sample Test", function() {
beforeEach(function() {
this.timeout(90000);
});
describe("Scroll Test", function() {
before(function() {
return client.init();
});
it("should scroll successfully", function() {
return client
.element("~mobile")
.setValue("1000000000")
.element("~continue")
.click()
.element("~passwordTextField")
.setValue("12345")
.element("~continue")
.click()
.element("~home")
.touchPerform([{
action: 'press',
options: {x: 60, y: 200}
},
{
action:'moveTo',
options: {x: 700, y: 200}
},
{
action: 'release'
}
])
.element("~article")
.click()
});
});
});
这段代码模拟了一个简单的登录操作,在 touchPerform() 之前它运行良好,它不执行任何滚动。
这是 Appium 所需的功能。
exports.options = {
desiredCapabilities: {
platformName: "android",
platformVersion: "5.1",
appPackage: "com.sample.app",
appActivity: "com.sample.app.MainActivity",
automationName: "uiautomator2",
avdReadyTimeout: "2000",
deviceName: "AVY9K17424903794",
app: "C:/Users/MdArifuzzaman/Arif/Appium Test/app-universal-
release.apk",
newCommandTimeout: 90
},
host: "127.0.0.1",
port: 4723
};
这是我的 package.json 文件。
{
"name": "sampletest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha scrollTest"
},
"author": "Md. Arifuzzaman",
"license": "ISC",
"dependencies": {
"appium": "^1.7.2",
"appium-uiautomator2-driver": "^1.1.1",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"mocha": "^5.0.0",
"wd": "^1.5.0"
},
"devDependencies": {
"randomstring": "^1.1.5",
"wdio-appium-service": "^0.2.3",
"wdio-mocha-framework": "^0.5.12",
"webdriverio": "^4.10.2"
}
}
【问题讨论】:
标签: javascript node.js mocha.js appium