标签: webdriver-io

NightwatchJS和WebdriverIO有什么区别?

正如标题所述,Nightwatch.js和Webdriver.io有什么区别?

看起来他们有相同的语法,并做几乎相同的事情.他们有什么不同?

我需要在它们之间做出选择.

nightwatch.js webdriver-io wdio-v4 wdio-v5

47
推荐指数
2
解决办法
2万
查看次数

使用 Appium 和 WebdriverIO 测试移动应用程序:“找不到 /session 的路线”

我想建立Android和iOS平台(React Native)移动应用程序的自动化测试流程。为此,我使用AppiumWebdriverIO。作为示例,我使用现有的appium-boilerplate代码库和现成的应用程序来运行测试。我在Android 模拟器中运行该应用程序。基本设置如下所示。

1.阿皮姆

在此输入图像描述

在此输入图像描述

2.WebdriverIO

wdio.shared.conf.js

exports.config = {
    // ====================
    // Runner and framework
    // Configuration
    // ====================
    runner: 'local',
    framework: 'jasmine',
    jasmineNodeOpts: {
        // Updated the timeout to 30 seconds due to possible longer appium calls
        // When using XPATH
        defaultTimeoutInterval: 90000,
        helpers: [require.resolve('@babel/register')],
    },
    sync: true,
    logLevel: 'silent',
    deprecationWarnings: true,
    bail: 0,
    baseUrl: 'http://the-internet.herokuapp.com',
    waitforTimeout: 10000,
    connectionRetryTimeout: 90000,
    connectionRetryCount: 3,
    reporters: ['spec'],

    // ====================
    // …
Run Code Online (Sandbox Code Playgroud)

android automated-tests appium webdriver-io react-native

15
推荐指数
3
解决办法
3万
查看次数

如何从WebdriverIO中继承WebElement

我正在寻找一种方法来继承webdriverio返回的WebElement对象,没有猴子修补和TS类型支持(自动完成是必须的).有没有办法做这样的事情?

class Checkbox extends WebdriverIOWebElement {
    constructor() {
       super($('div'))
    }
    // overriding base method
    isDisplayed(): boolean {
        // blabla some new logic here
    }

    check() {
        if(!this.isChecked()) {
            this.click()
        }
    }

    uncheck() {
        if(this.isChecked()) {
            this.click()
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript webdriver selenium-webdriver typescript webdriver-io

11
推荐指数
1
解决办法
412
查看次数

加载角度SPA时的org.openqa.selenium.TimeoutException

我正在使用chimp.js,它通过一些光纤魔法来增强webdriver.io,以便可以以同步方式定义代码.这是代码:

var c = require('./config');

module.exports = function () {
    this.When(/^I try to login with wrong credentials$/, function () {
        browser.setValue(userNameField, wrongUser);
        browser.setValue(passwordField, wrongPassword);
        browser.click('button[value="Login"]');
    });
    this.When(/^I try to login with the correct credentials$/, function () {
        browser.setValue(userNameField, c.userName);
        browser.setValue(passwordField, c.password);
        console.log('before pressig the button');
        browser.click('button[value="Login"]');
        console.log('logged in');
    });
};
Run Code Online (Sandbox Code Playgroud)

第一个When执行得很好.第二个When也有效,我只是没有看到

登录

在控制台上.两者都在同一个网站上运行,并且都点击了同一个按钮.在第二种情况下,登录成功后,浏览器将重定向到角度SPA.这里的一切都正确加载,但就是这样.回调永远不会发生.

--debug --log=command我运行测试看到这是最后一行(在超时之前)

[1;30m[01:30:18]: [0m [0;35mCOMMAND [0mPOST      "/wd/hub/session/7c334efe-2417-4184-b43c-082ba4441291/element/11/click"
Run Code Online (Sandbox Code Playgroud)

将日志级别切换为详细,并等待〜5min我收到以下错误:

[chimp][selenium.stderr] 01:36:59.561 DEBUG - Executed: [0560aaa14e4cf874afd72336c19e299b, clickElement {id=0.6384125368203968-3}]

[chimp][selenium.stderr] 01:37:02.449 WARN …
Run Code Online (Sandbox Code Playgroud)

selenium angularjs chrome-web-driver webdriver-io chimp.js

8
推荐指数
1
解决办法
910
查看次数

当窗口位于 Chrome 87 的后台时,Webdriver.io/Selenium 测试失败

我刚刚升级到最新版本的 Chrome 87。无论 Chrome 窗口是在前台还是后台,我的 Webdriver.io/Selenium 测试都可以正常运行。现在,升级后,如果窗口在前台,则测试通过,但如果它在后台则不通过。

我没有最小化运行我的测试的 Chrome 窗口。我只是按 Alt+Tab,这样我的 IDE 就在 Chrome 前面,它在后面。

我知道 Chrome 87 有一个新的“功能”,如果它不在前台,它会使用更少的 CPU。有没有办法使用 Chrome 或 Chromedriver 设置关闭它?

似乎我的测试是找到要点击的按钮,但 Chrome 没有注册点击。

webdriver node.js selenium-webdriver webdriver-io

8
推荐指数
2
解决办法
1574
查看次数

WebdriverIO与Selenium Webdriver(Java方法)

有关WebdriverIO与Selenium的反馈意见吗?我处于两难境地,想要消除这种困惑.

我花了几天时间学习WebdriverIO并做了一些实践,但得出的结论还不够成熟.调试确实是一个挑战.

java node.js selenium-webdriver webdriver-io

7
推荐指数
2
解决办法
1万
查看次数

第二次测试不会改变URL

我有两个测试.第一次测试成功通过.然后在第二个测试中有一个url方法调用,但它不会更改浏览器中的url.

wdio.conf.js中的baseUrl设置为http://localhost/web/es/index.html#

测试:

var assert = require('assert');

describe('user login ', function(){

    it('user login', function(){

        browser
            .url('/system/login')
            .setValue('[name="username"]','test')
            .setValue('[name="password"]','test')
            .click('=Potvr?');            

        assert(browser.waitUntil('=test test'));                
    });

    it('user form', function(){

        browser
            .url('/user/form');
    });
});
Run Code Online (Sandbox Code Playgroud)

在第一次测试/ system/login中正确打开.但在第二次测试中,网址永远不会更改为/ user/form

我刚开始使用webdriverio所以我错过了什么?

javascript webdriver-io

7
推荐指数
1
解决办法
524
查看次数

使用spectron测试电子应用程序重新启动时丢失webdriverio会话

我正在使用spectron对我的电子应用程序运行集成测试.除了尝试测试应用程序设置在应用程序重新启动之间正确保留之外,一切正常.

在运行测试时,我的应用程序启动userData每个测试的新临时目录,以确保测试被隔离.这意味着持久性测试需要理想地在单个测试中进行,为实现这一点,我必须在测试过程中重新启动应用程序.有一种app.restart方法,所以必须得到支持吗?

我正在使用以下光谱测试代码:

// save some settings here

await app.restart();
await app.client.waitUntilWindowLoaded()

// do some more checking to ensure the app is fully loaded
// check the settings here
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

Error: waitUntilWindowLoaded Promise was rejected with the following reason: 
Error: A session id is required for this command but wasn't found in the response payload
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?我也尝试停止Application实例并启动一个具有类似结果的新实例.

webdriver-io electron spectron

7
推荐指数
1
解决办法
813
查看次数

挂在Yarn上的Fibers/node-gyp安装在Windows上

貌似wdiofibers作为依赖,使用node-gyp,这显然不会没有的Python 2.7在Windows上运行.

现在我已经安装了,我没有得到"missing PYTHON"错误,但它永远挂在命令正在做的任何事情 - 光纤.

永远挂在纤维上

javascript node.js node-gyp webdriver-io yarnpkg

7
推荐指数
1
解决办法
386
查看次数

JEST:“异步回调未在jest.setTimeout指定的5000ms超时内调用”。

在您指出之前,是的,我知道这似乎是多个问题的重复。

但是,我实现了建议的所有3个修复程序;

  • jest.setTimeout()在测试中使用以设置异步超时
  • 使用第三个参数test()传递扩展的异步超时限制
  • done完成后调用函数

但是,在自动Linux机器(Jenkins)上运行我的笑话测试时,它仍然会抛出相同的错误。另外,值得一提的是,这在运行NodeJS v10的MacOS计算机上运行良好,而自动化的Linux计算机运行NodeJS V8.8.3(最新的LTS版本)

这就是我开玩笑的测试结果。

const webdriverio = require('webdriverio');
const options = {
    desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
            args: ["--no-sandbox", "disable-web-security", "--disable-dev-shm-usage"]
        } 
    } 
};
const client = webdriverio.remote(options);

beforeEach(async () => {
    await client.init();
})

test('Google Search for WebdriverIO has correct title', async (done) => {
    jest.setTimeout(30000)
    await client.url('https://www.google.com/ncr');
    await client.setValue('input[name=q]', 'WebdriverIO');
    await client.click('input[value="Google Search"]');
    const title = await client.getTitle();
    expect(title).toBe('WebdriverIO - Google Search');
    done();
}, 30000);

afterEach(async …
Run Code Online (Sandbox Code Playgroud)

javascript selenium-webdriver webdriver-io jestjs

7
推荐指数
1
解决办法
5351
查看次数