0

ログインページの「パスワードからテキストへ」機能のクリックが機能することを確認しようとしているようなナイトウォッチテストがあります。

 'Test Password Visible': function (client) {
        client
            .url('http://127.0.0.1:8000/test')
            .waitForElementVisible('body', 1000)
            .assert.visible('#id_password')
            .assert.visible('#eye_button')
           .pause(1000)

        client.assert.attributeEquals("#id_password", "type", "password");

        client.execute(function () {
            document.querySelector('#eye_button').click()
            console.log('clicked')
        }, []);
        client.assert.attributeEquals("#id_password", "type", "text");
        
    },

#eye_buttondivパスワード<i>フィールドがtype=textまたはtype=password

私はナイトウォッチを初めて使用しますが、他の投稿を見ると、div をクリックできるようになっているはず.click()です。要素がインタラクティブではないため、メソッドが機能しなかったことに注意してください。

client.execute(function () {
            document.querySelector('#eye_button').click()
            console.log('clicked')
        }, []);

ただし、そうではなく、テストの実行時に console.log を取得することさえできません。誰かが私を正しい方向に向けるのを手伝ってくれますか?

divがクリックされておらず、パスワードフィールドを変換するJSが呼び出されていないため、失敗する行は次のとおりです。

client.assert.attributeEquals("#id_password", "type", "text");

4

2 に答える 2