首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >应用程序与WebdriverIO集成

应用程序与WebdriverIO集成
EN

Stack Overflow用户
提问于 2020-08-04 11:49:19
回答 1查看 393关注 0票数 0

我正在尝试将Applitools与WebdriverIO项目集成起来。详情如下:

  • 节点版本: v12.18.2
  • 国家预防机制版本: 6.14.5
  • wdio版本: 6.3.6

我的wdio文件有如下所示的服务:

代码语言:javascript
复制
services: ['selenium-standalone'],

接下来,我使用命令npm install '@applitools/eyes.webdriverio' --save-dev安装applitools。现在,当我使用npm run test运行项目时,我得到了以下错误:

代码语言:javascript
复制
    > webdriverio-applitools_1@1.0.0 test D:\WebDriverIO\WebDriverIo-Applitools_1
> wdio wdio.conf.js


Execution of 1 spec files started at 2020-08-04T11:33:02.577Z

2020-08-04T11:33:02.725Z INFO @wdio/cli:launcher: Run onPrepare hook
2020-08-04T11:33:04.515Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2020-08-04T11:33:04.518Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js
[0-0] 2020-08-04T11:33:04.903Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2020-08-04T11:33:04.911Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
[0-0] RUNNING in chrome - D:\WebDriverIO\WebDriverIo-Applitools_1\main\visual.js
[0-0] 2020-08-04T11:33:06.448Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-08-04T11:33:06.449Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session
[0-0] 2020-08-04T11:33:06.450Z INFO webdriver: DATA {
  capabilities: {
    alwaysMatch: { browserName: 'chrome', acceptInsecureCerts: true },
    firstMatch: [ {} ]
  },
  desiredCapabilities: { browserName: 'chrome', acceptInsecureCerts: true }
}
[0-0] 2020-08-04T11:33:09.975Z INFO webdriver: COMMAND getTitle()
[0-0] 2020-08-04T11:33:09.975Z INFO webdriver: [GET] http://localhost:4444/wd/hub/session/4e3081702a2e0e07eba23d42fa81fce4/title
[0-0] Title of page is [object Promise]
[0-0] 2020-08-04T11:33:09.980Z INFO webdriver: COMMAND navigateTo("https://applitools.com/helloworld")
[0-0] 2020-08-04T11:33:09.980Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session/4e3081702a2e0e07eba23d42fa81fce4/url
2020-08-04T11:33:09.980Z INFO webdriver: DATA { url: 'https://applitools.com/helloworld' }
[0-0] TypeError in "my first visual test should look visually perfect"
browser.getViewportSize is not a function
[0-0] 2020-08-04T11:33:09.988Z INFO webdriver: COMMAND deleteSession()
[0-0] 2020-08-04T11:33:09.988Z INFO webdriver: [DELETE] http://localhost:4444/wd/hub/session/4e3081702a2e0e07eba23d42fa81fce4
[0-0] 2020-08-04T11:33:09.997Z INFO webdriver: RESULT
[0-0] FAILED in chrome - D:\WebDriverIO\WebDriverIo-Applitools_1\main\visual.js
2020-08-04T11:33:12.348Z INFO @wdio/cli:launcher: Run onComplete hook
2020-08-04T11:33:12.349Z INFO @wdio/selenium-standalone-service: shutting down all browsers

 "spec" Reporter:
------------------------------------------------------------------
[chrome 84.0.4147.105 windows #0-0] Spec: D:\WebDriverIO\WebDriverIo-Applitools_1\main\visual.js
[chrome 84.0.4147.105 windows #0-0] Running: chrome (v84.0.4147.105) on windows
[chrome 84.0.4147.105 windows #0-0] Session ID: 4e3081702a2e0e07eba23d42fa81fce4
[chrome 84.0.4147.105 windows #0-0]
[chrome 84.0.4147.105 windows #0-0] my first visual test
[chrome 84.0.4147.105 windows #0-0]    ✖ should look visually perfect
[chrome 84.0.4147.105 windows #0-0]
[chrome 84.0.4147.105 windows #0-0] 1 failing (2.2s)
[chrome 84.0.4147.105 windows #0-0]
[chrome 84.0.4147.105 windows #0-0] 1) my first visual test should look visually perfect
[chrome 84.0.4147.105 windows #0-0] browser.getViewportSize is not a function
[chrome 84.0.4147.105 windows #0-0] TypeError: browser.getViewportSize is not a function
[chrome 84.0.4147.105 windows #0-0]     at Context.<anonymous> (D:\WebDriverIO\WebDriverIo-Applitools_1\main\/visual.js:15:42)
[chrome 84.0.4147.105 windows #0-0]     at Context.executeAsync (D:\WebDriverIO\WebDriverIo-Applitools_1\node_modules\@wdio\utils\build\shim.js:123:21)
[chrome 84.0.4147.105 windows #0-0]     at Context.testFrameworkFnWrapper (D:\WebDriverIO\WebDriverIo-Applitools_1\node_modules\@wdio\utils\build\test-framework\testFnWrapper.js:49:28)


Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:09

2020-08-04T11:33:12.353Z INFO @wdio/local-runner: Shutting down spawned worker
2020-08-04T11:33:12.603Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2020-08-04T11:33:12.604Z INFO @wdio/local-runner: shutting down
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriverio-applitools_1@1.0.0 test: `wdio wdio.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriverio-applitools_1@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\soham\AppData\Roaming\npm-cache\_logs\2020-08-04T11_33_12_626Z-debug.log

我有一个测试用例,看起来如下:

代码语言:javascript
复制
const {Eyes, Target} = require('@applitools/eyes.webdriverio');
const eyes = new Eyes();
eyes.setApiKey('API KEY');

describe('my first visual test', function () {
    it('should look visually perfect', async function () {
        browser.url('./helloworld');

        const pageTitle = browser.getTitle();

        console.log(`Title of page is ${pageTitle}`)

        
        try {
            //const viewportSize = browser.getViewportSize();
    
            await eyes.open(browser, 'Hello World!', 'My first Javascript test!');

            await eyes.check('Main Page', Target.window());

            browser.click('button');

            await eyes.check('Click!', Target.window());

            await eyes.close();
        } finally {
            await eyes.abortIfNotClosed();
        }
    })
});

有人能告诉我我在这里错过了什么吗?或者我该怎么做?

EN

回答 1

Stack Overflow用户

发布于 2020-08-04 17:25:21

这位是Applitools的索菲。我看到您使用的是wdio 6,在本例中,尝试安装@applitools/eyes webdriverio(它与wdio 5和6兼容)和删除@applitools/eyes.webdriverio (与wdio 4兼容)。

请注意,此包不支持傀儡者协议,而只支持webdriver协议。

这里是我们关于使用eyes wdio 5包的教程

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63246256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档