我正在尝试将codeceptjs I.fillField()函数发送到android native应用中的登录字段。由于某种原因,webdriver被字符串文字的电子邮件名称或上一个命令中刚使用的对象所混淆。
错误命令elementSendKeys的“文本”参数的格式错误
预期:字符串
实际:对象
控制台输出
jason@LAPTOP-K0PQTR0L C:\Users\jason\Desktop\React-App-Automation\appium
$ codeceptjs run --verbose --grep @gg
CodeceptJS v2.1.0
Using test root "C:\Users\jason\Desktop\React-App-Automation\appium"
Helpers: Appium, AppiumHelper
Plugins: screenshotOnFail
Test Pizza Menu Items Pricing and Calories --
[1] Starting recording promises
Emitted | suite.before ([object Object])
Validate all menu items, calories and pricing @regression @sanity @validMenuPizza @gg
Emitted | test.before ([object Object])
Emitted | hook.start ([object Object])
Emitted | hook.passed ([object Object])
Emitted | test.start ([object Object])
Emitted | step.before (I wait for element {"xpath":".//*[contains(@class, 'EditText')]"}, 20)
Emitted | step.after (I wait for element {"xpath":".//*[contains(@class, 'EditText')]"}, 20)
Emitted | step.before (I fill field {"xpath":".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com")
Emitted | step.after (I fill field {"xpath":".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com")
Emitted | step.before (I fill field {"xpath":"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android....
Emitted | step.after (I fill field {"xpath":"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.v...
Emitted | step.before (I click {"xpath":"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view....
Emitted | step.after (I click {"xpath":"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.V...
Emitted | step.start (I wait for element {"xpath":".//*[contains(@class, 'EditText')]"}, 20)
Runner: runTest
I wait for element {"xpath":".//*[contains(@class, 'EditText')]"}, 20
Emitted | step.passed (I wait for element {"xpath":".//*[contains(@class, 'EditText')]"}, 20)
Emitted | step.finish (I wait for element {"xpath":".//*[contains(@class, 'EditText')]"}, 20)
Emitted | step.start (I fill field {"xpath":".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com")
I fill field {"xpath":".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com"
» [Elements] Using first element out of 2
[1] Error | Error: Malformed type for "text" parameter of command elementSendKeys
Expected: string
Actual: object
For more info see https://w3c.github.io/webdriver/#dfn-element-send-keys
Emitted | step.failed (I fill field {"xpath":".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com")
Emitted | step.finish (I fill field {"xpath":".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com")
[1] Error | Error: Malformed type for "text" parameter of command elementSendKeys
Expected: string
Actual: object
For more info see https://w3c.github.io/webdriver/#dfn-element-send-keys
[1] Starting <teardown> session
Emitted | test.failed ([object Object])
Emitted | test.finish ([object Object])
[1] <teardown> Stopping recording promises
» <screenshotOnFail> Test failed, saving screenshot
» Screenshot has been saved to C:\Users\jason\Desktop\React-App-Automation\appium\output\Validate_all_menu_items,_calories_and_pricing_@regression_@sanity_@validMenuPizza_@gg.failed
.png
× FAILED in 4868ms
[2] Starting recording promises
Emitted | test.after ([object Object])
Emitted | suite.after ([object Object])
-- FAILURES:
1) Test Pizza Menu Items Pricing and Calories
Validate all menu items, calories and pricing @regression @sanity @validMenuPizza @gg:
Malformed type for "text" parameter of command elementSendKeys
Expected: string
Actual: object
For more info see https://w3c.github.io/webdriver/#dfn-element-send-keys
Scenario Steps:
- I.fillField({"xpath":".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com") at Test.<anonymous> (features\Pizza\PizzaMenuTests.js:26:5)
- I.waitForElement({"xpath":".//*[contains(@class, 'EditText')]"}, 20) at Test.<anonymous> (features\Pizza\PizzaMenuTests.js:25:5)
Error: Malformed type for "text" parameter of command elementSendKeys
Expected: string
Actual: object
For more info see https://w3c.github.io/webdriver/#dfn-element-send-keys
at Element.<anonymous> (C:\Users\jason\AppData\Roaming\npm\node_modules\webdriverio\node_modules\webdriver\build\command.js:66:15)
at Element.<anonymous> (C:\Users\jason\AppData\Roaming\npm\node_modules\webdriverio\build\middlewares.js:55:41)
at Element.addValue (C:\Users\jason\AppData\Roaming\npm\node_modules\webdriverio\build\commands\element\addValue.js:38:17)
at Element.<anonymous> (C:\Users\jason\AppData\Roaming\npm\node_modules\webdriverio\build\middlewares.js:55:41)
at Element.setValue (C:\Users\jason\AppData\Roaming\npm\node_modules\webdriverio\build\commands\element\setValue.js:35:15)
at process._tickCallback (internal/process/next_tick.js:68:7)
FAIL | 0 passed, 1 failed // 23s
Emitted | global.result ([object Object])
Emitted | global.after ([object Object])
提供相关的测试源代码
Scenario("Validate all menu items, calories and pricing @regression @sanity @validMenuPizza @gg", async function(I) {
I.waitForElement({"xpath": ".//*[contains(@class, 'EditText')]"}, 20);
I.fillField({"xpath": ".//*[contains(@class, 'EditText')]"}, "Jason.legako@yum.com");
}
exports.config = {
"tests": "features/*/*Tests.js",
"output": "./output",
"helpers": {
"Appium": {
app: "C:\\Users\\jason\\Desktop\\React-App-Automation\\appium\\data\\envs\\app-uatNoPinning.apk",
platform: "Android",
device: "Nexus5x",
desiredCapabilities: {
appActivity: "MainActivity",
deviceName: "Nexus5x",
platformVersion: "8.1.0",
automationName: "uiautomator2", // Selendroid Espresso
},
},
"AppiumHelper": {
require: "./appium_helper.js",
},
},
"include": {
"commonActions": "./pageactions/CommonActions.js",
},
"bootstrap": null,
"mocha": {},
"name": "appium",
};