Giter Site home page Giter Site logo

testcafe-browser-provider-webdriverio's Introduction

testcafe-browser-provider-webdriverio

This is the webdriverio browser provider plugin for TestCafe. It uses the latest version of webdriverio to connect to Selenium/Appium server.

Install

npm install -D https://github.com/fnlctrl/testcafe-browser-provider-webdriverio.git

Prerequisites

A selenium compatible server (Selenium, Selenoid, Zalenium, Appium, etc.) up and running.

Also note that this plugin requires node>=7.6 with native async/await support

Usage

If you run tests from the command line, use the browser alias when specifying browsers. The '-c 2' parameter will split the tests up and run them across two browsers concurrently. Omit this if it is not needed.

testcafe -c 2 webdriverio:chrome 'path/to/test/file.js'

When you use API, pass the alias to the browsers() method:

testCafe
    .createRunner()
    .src('path/to/test/file.js')
    .browsers('webdriverio:chrome')
    .concurrency(2)
    .run();

Specifying the Browser/Platform/Device

The browser version and platform can be specified along with the browser name alias in the format:

webdriverio:browserName[@version][:platform][:device]

For example:

When using with Appium server, device name must be specified:

  • webdriverio:chrome:android:my-device-name

for android devices, device names can be found with adb devices

Configuration

Use the following optional environment variable to set additional configuration options:

  • REMOTE_HOST - (optional) the hostname to the remote server. Default: 'localhost'.

  • REMOTE_PORT - (optional) the port to the remote server. Default: '4444'.

  • ENABLE_VNC - (optional) use ENABLE_VNC=true to add enableVNC: true in capabilities option for webdriverio. Default: false.

testcafe-browser-provider-webdriverio's People

Contributors

dependabot[bot] avatar fnlctrl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

testcafe-browser-provider-webdriverio's Issues

ERROR webdriver: Request failed due to Error: getaddrinfo ENOTFOUND http http:80

Hi!
Besides Selenium Grid server, I have two packages installed in my testing env (pls disregard the config I have):

  • testcafe-browser-provider-webdriverio
  • testcafe-browser-provider-selenium

While using testcafe-browser-provider-selenium to execute the tests on the selenium server on a chrome browser, I get a pass/fail for the tests meaning everything is working.

While using testcafe-browser-provider-webdriverio to execute the tests on the selenium server on a chrome browser, I get this err:

ERROR webdriver: Request failed due to Error: getaddrinfo ENOTFOUND http http:80
ERROR Was unable to open the browser "webdriverio:chrome" due to error.

Error: getaddrinfo ENOTFOUND http http:80
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)

The only 2 differences between the above packages are:

  1. inside the npm script commands for selenium I have: ... selenium:chrome ... ; for webdriverio I have: ... webdriverio:chrome ...
  2. the packages itself (but here I can't do nothing about it);

Can you please give some hint on how to go on?
Thank you

PS: if I'm trying to use the package with an appium command to execut tests, I get the same err as posted above.

App capabilities

Hi Team
I am new to this plugin, trying to automate native app using testcafe+testcafe-browser-provider-webdriverio.
I am able to run test in mobile browsers, but i am unable to find a good example for automating app in windows/mac platform.
Could you please explain how to pass capabilities in testcafe, like below so that app can be tested
capabilities: {
platformName: "Android",
platformVersion: "8.0.0",
deviceName: "xxxxxx",
// or app: "https://path to apk",
appPackage: "com.xxx.xxx.android",
newCommandTimeout: 4500,
appActivity: "com.xxx.xxx.android.xxxx",

}

while installing: npm ERR! code ENOLOCAL

hi @fnlctrl .
I've just tried to install this package, according to the readme file, but I'm encountering this error:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "github.com:fnlctrl\testcafe-browser-provider-webdriverio.git" as it does not contain a package.json file.

ps: besides node v8.12.0

LATER EDIT:
after trying to npm clear cache -f, rm node_modules, both and some other tries, what sorted out the installation of the package was: delete the node_modules and adding the repo path directly into my package.json:

"devDependencies": {
...
"testcafe-browser-provider-webdriverio": "git+https://github.com/fnlctrl/testcafe-browser-provider-webdriverio.git"
... }

No default value for hostname

Below code doesn't include default value for hostname property passed to wdio.remote which results in error due to trim() operation on undefined value when REMOTE_HOST environment variable is not set.

let browser = await wdio.remote({
  capabilities,
  port: parseInt(REMOTE_PORT) || 4444,
  hostname: REMOTE_HOST.trim(),
  logLevel: CI ? 'silent' : 'error'
});

Solution:
Replace hostname: (...) with hostname: REMOTE_HOST ? REMOTE_HOST.trim() : 'localhost'

Best regards

Screenshot support

Thank you for your provider!

Screenshots are useful and supported in testcafe and appium.
Do you have plans to realize this feature?

Wait for session delete in closeBrowser()

Using chromedriver standalone with testcafe and testcafe-browser-provider-webdriverio plugin, after running tests, chromedriver needs to be stopped explicitily.

In same time after tests, testcafe.close() is called which triggers closeBrowser() from testcafe-browser-provider-webdriverio.

However because chromedriver stops before deleteSession() is called, webdriver throws exception ERROR webdriver: Request failed due to Error: connect ECONNREFUSED 127.0.0.1:9515.

Solution would be to wait for deleteSession() and make sure testcafe.close() is called before chromedriver.stop().

So in async closeBrowser() add await keyword to deleteSession() call.

async closeBrowser(id) {
    await this.browsers[id].deleteSession();
    delete this.browsers[id];
    clearInterval(this.heartbeats[id]);
    delete this.heartbeats[id];
},

Best regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.