首页 > 解决方案 > CodeceptJS locator.stringify 在使用 Appium 运行 codecept 时不是函数错误

问题描述

我有一个非常简单的脚本,我试图在 Appium 中使用“fillField”填充网站中的用户名字段,但我收到此错误“locator.stringify 不是函数”。我无法弄清楚是什么问题。任何帮助表示赞赏。这是详细的输出 -

[1] Starting recording promises
    Emitted | suite.before ([object Object])
  test something
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "https://xxxxxxxxx.com/#login")
    Emitted | step.after (I am on page "https://xxxxxxxxx.com/#login")
    Emitted | step.before (I wait 6)
    Emitted | step.after (I wait 6)
    Emitted | step.before (I fill field "username", "hello@world.com")
    Emitted | step.after (I fill field "username", "hello@world.com")
    Emitted | step.start (I am on page "https://xxxxxxx.com/#login")
    I am on page "https://xxxxxxxxxxx.com/#login"
    Emitted | step.passed (I am on page "https://xxxxxxx.com/#login")
    Emitted | step.finish (I am on page "https://xxxxxxxx.com/#login")
    Emitted | step.start (I wait 6)
    I wait 6
    Emitted | step.passed (I wait 6)
    Emitted | step.finish (I wait 6)
    Emitted | step.start (I fill field "username", "hello@world.com")
    I fill field "username", "hello@world.com"
    [1] Error | TypeError: locator.stringify is not a function
    Emitted | step.failed (I fill field "username", "hello@world.com")
    Emitted | step.finish (I fill field "username", "hello@world.com")
    [1] Error | TypeError: locator.stringify is not a function
    [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 /Users/qa-engg/Documents/codeceptJS/appium/output/test_something.failed.png
  ✖ FAILED in 9740ms

    [2] Starting recording promises
    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

-- FAILURES:

  1) IP mobile
       test something:
     locator.stringify is not a function

标签: codeceptjs

解决方案


看起来您发现了一个错误,它是 2017 年 12 月制造的。很快,就会修复。

作为解决方法,使用不同的定位器,而不仅仅是字符串“用户名”。例如 CSS、Xpath、Strict 定位器。


推荐阅读