【问题标题】:Protractor testing i cant get acces to input value using sendkeys量角器测试我无法使用 sendkeys 访问输入值
【发布时间】:2020-07-03 20:07:02
【问题描述】:

我无法将密钥发送到以下输入(只有在这里我失败了,其余的都是工作)。 我收到错误消息:

StaleElementReferenceError: stale element reference: element is not attached to the page document

代码:

test('Should insert an invalid password', async done => {
        const css = by.css('[id=password111]')
        const password = await element(css)
        await password.clear()
        await password.sendKeys('tom')
        // await submitForm()
        done()
    })

html:

<nz-input-group [id]="'passwordContainer'" [nzSuffix]="passwordSuffixTemplate" nzSize="large">
    <input [id]="'password111'"
           class="cdf-input"
           [type]="passwordVisible ? 'text' : 'password'"
           nz-input
           nzSize="large"
           [required]="passwordAuth"
           [formControlName]="'password'"
           [placeholder]="'Password'"
    />
</nz-input-group>

谁知道我哪里错了??

【问题讨论】:

    标签: selenium selenium-webdriver css-selectors protractor angular-test


    【解决方案1】:

    试试下面的代码:

    before() {
    browser.waitForAngularEnabled(true);
    }
    test('Should insert an invalid password', async () => {
            const css = by.css('[id=password111]')
            const password = element(css)
             password.clear()
             password.sendKeys('tom')
            // await submitForm()
        })

    注意:您不能同时使用异步和完成回调。 欲了解更多信息,请访问此链接https://www.protractortest.org/#/timeouts

    【讨论】:

      【解决方案2】:

      使用预期条件等待陈旧。

      const expected = require('protractor').ExpectedConditions
      browser.wait(expected.stalenessOf(loc.customer_login),undefined,'msg')
      

      https://www.protractortest.org/#/api?view=ProtractorExpectedConditions.prototype.stalenessOf

      请参阅此链接以了解陈旧的元素引用错误: https://developer.mozilla.org/en-US/docs/Web/WebDriver/Errors/StaleElementReference

      【讨论】:

        猜你喜欢
        • 2018-12-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-20
        • 1970-01-01
        • 1970-01-01
        • 2014-01-04
        相关资源
        最近更新 更多