Can I rewrite webdriver v4 test method chain to v5 (current spectron / electron testing)

52 views Asked by At

I use spectron / electron testing. Spectron update change to webdriver v5. I have UI test written in v4 method chain. Can I rewrite webdriver v4 test method chain to webdriver v5(current spectron)?

it("input basic test", function() {
    return this.app.client.waitForVisible('#query-area__query-input__input')
            .waitForEnabled('#query-area__query-input__input')
            .clearElement('#query-area__query-input__input')
            .setValue('#query-area__query-input__input', "Bonan matenon!")
            .getValue('#query-area__query-input__input')
            .then(function(text){assert(text === 'Bonan matenon!')})
})

in https://github.com/MichinariNukazawa/lina_dicto/blob/master/lina_dicto/test/input_ui.js

I know need replace some method and element id selector. see my spectron issue url: https://github.com/electron-userland/spectron/issues/663

1

There are 1 answers

0
michinari nukazawa On

old spectron(WebdriverIO v4 method chaining)


    it("input basic test", function() {
        return this.app.client.waitForVisible('#query-area__query-input__input')
                .waitForEnabled('#query-area__query-input__input')
                .clearElement('#query-area__query-input__input')
                .setValue('#query-area__query-input__input', "Bonan matenon!")
                .getValue('#query-area__query-input__input')
                .then(function(text){assert(text === 'Bonan matenon!')})
    })

new spectron(WebderiverIO v5 async/await)


    it("input basic test", async function() {

        const inputElement = await this.app.client.$('#query-area__query-input__input');
        let text;
        text = await inputElement.getValue();
        console.log(`before:'${text}'`);
        await inputElement.waitForEnabled()
        await inputElement.clearValue()
        await inputElement.setValue("Bonan matenon!")
        text = await inputElement.getValue();
        console.log(`after:'${text}'`);
        assert(text === 'Bonan matenon!')
        // assert(text === '') // test to test (falure)
    })