Giter VIP home page Giter VIP logo

v4's Introduction

WebdriverIO WebdriverIO

Build Status NPM version Dependency Status npm Coveralls Gitter

Selenium Test Status


This library is a Webdriver (browser automation) module for Node.JS. It makes it possible to write super easy Selenium tests in your favorite BDD/TDD test framework, that will run locally or in the cloud using Sauce Labs, BrowserStack or TestingBot.

WebdriverIO is agnostic with regards to the test framework you want to use. Cucumber, Jasmine and Mocha+Chai are supported by the configuration wizard.

Installation

npm install webdriverio

or if you want to use the wdio test runner

npm install -g webdriverio

Getting started

Simply run wdio config and the configuration helper wizard will get you set up:

wdio wizard

With all that done, have a look at the many examples.

Plugins

Grunt Integration Gulp Integration Sublime Text Plugin Atom.io Plugin Visual Regression Testing with Applitools Eyes WebRTC Analytics Plugin

Syntax example

browser.url('http://google.com');
$('#q').setValue('webdriver');
$('#btnG').click();

Notice how this is far simpler than with the original selenium-webdriverjs,

driver.get('http://www.google.com');
driver.findElement(webdriver.By.id('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.id('btnG')).click();

and significantly simpler than with WD.js:

browser
  .get("http://www.google.com")
  .elementById('q')
  .sendKeys('webdriver')
  .elementById('btnG')
  .click()

For more details on the comparison between WebdriverIO, selenium-webdriverjs and WD.js, read this discussion. Also see more WebdriverIO examples in the example folder.

Need help?

If you have questions or any problems using WebdriverIO join the Gitter Chat, hit us contributor on Twitter or just file an issue on Github. We will try to get back to you as soon as possible.

Also if you miss any feature, let us know so we can make WebdriverIO even better. For news or announcements check @WebdriverIO on Twitter.

NPM Maintainers

The npm module for this library is maintained by:

History

WebdriverIO was originated by Camilo Tapia's initial Selenium project called WebdriverJS, which was the first webdriver project on NPM. In 2014, the project was renamed WebdriverIO later on.

License

MIT

v4's People

Contributors

amilajack avatar apergy avatar camme avatar christian-bromann avatar dandv avatar danjenkins avatar emilyrohrbough avatar fijijavis avatar filaraujo avatar georgecrawford avatar hanneshal avatar hborawski avatar j0tunn avatar jankcat avatar just-boris avatar klamping avatar l-hunter avatar mattc41190 avatar monolithed avatar patthiel avatar pipporaimondi avatar risto-stevcev avatar robinfr avatar sa-spag avatar sbmaxx avatar timbru31 avatar tuhuynhvan avatar vvo avatar willbrock avatar ysono avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

v4's Issues

'Socket hang up' errors started occurring consistently (but intermittently on different tests/steps) after 8-11 sceanarios in a wdio-cucumber-framework feature file

(This is a resubmit of webdriverio/webdriverio#3460, erroneously filed under webdriverio master. Resubmitting here as it pertains to v4.)

The following 'socket hang up' error occurs on different steps starting on the 8th to 11th scenario in a given feature file, where the previous scenarios, usually with the same sequence of steps as the failing one, run fine. Up until last November, all were running fine and passing, for ~1yr.

The subsequent 4 tests also fail with 'socket hang up', while the following few tests will fail with error 'A session id is required for this command but wasn't found in the response payload', and then will start passing again.

A new session is started with each scenario, as browser.reload() gets called on starting a scenario. The initial 'socket hang up' error occurs usually 4-5 steps into the scenario, while subsequent ones occur on the first step of the scenario.

This is on Chrome, and was working perfectly until ~last November. Similar intermittent 'A session id is required for this command but wasn't found in the response payload' errors had always occurred on IE10 and IE11 (with no 'socket hang up').

Concurrent with the error, a browser window gets opened but doesn't get resized or attempt to navigate to the application url, and stays open while new windows get generated for new scenarios.

It happens with every feature file run, both using selenium-standalone locally, wdio testrunner and Selenium Grid Extras via Jenkins.

"Error: socket hang up
at createHangUpError (_http_client.js:302:15)
at Socket.socketOnEnd (_http_client.js:394:23)
at emitNone (events.js:91:20)
at Socket.emit (events.js:186:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)"

Environment (please complete the following information):

selenium-standalone 3.141.0

* **WebdriverIO version:** 4.8.0

* **Mode:** Both

* **If WDIO Testrunner, running sync/async:**  sync

* **Node.js version:**  8.9.0

* **NPM version:** 5.6.0

* **Browser name and version:**  Chrome 71.0.3578.98
  --Driver:  Chromedriver 2.45.0

* **Platform name and version:** Any : Windows 10, Windows 8.1

* **Additional wdio packages used (if applicable):**
  wdio-cucumber-framework:  1.1.0

Additional context
Add any other context about the problem here.

With chromedriver versions <=2.43, the following concurrent error also occurs in the selenium log as noted below, with trace: "java.lang.IllegalStateException: Committed".

With chromedriver 2.45, the same 'Socket hang up' error occurs as the step error in the wdio output, but the java.lang.illegalStateException: Committed is not output, and instead the selenium-standalone log shows multiple sessions created and removed without intervening output, as follows:

Starting ChromeDriver 2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387) on port 42068
Only local connections are allowed.
15:51:45.018 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
15:51:45.033 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session ee949d62bb60cec80c97246fe5f21c13 (org.openqa.selenium.chrome.ChromeDriverService)
15:51:45.506 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
15:51:45.538 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session ff3758d7f2582b39ee02e3f6657ebabd (org.openqa.selenium.chrome.ChromeDriverService)
15:51:46.887 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
15:51:46.921 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 40e0db5140996cd8a2e044f1901aeea6 (org.openqa.selenium.chrome.ChromeDriverService)
15:51:52.438 INFO [ActiveSessions$1.onStop] - Removing session

This corresponds to logger output of messages being logged in before and after-scenario hooks, like

"in beforeScenario
in afterScenario
in beforeScenario
in afterScnenario"

without intervening logging, which normally occurs while a scenario is executed. (The 'Socket hang up' error is output at then end of the run, as the Step/scenario error trace).

Here is a zip file to reproduce the issue against google.com:

google_search_reproduce_socket_hangup_with_isc_folders.zip

(command to run: 'wdio config\wdio.conf.js --suite search - error occurs on 1st, 2nd or 3rd TC)

However, bizarrely, it's not reproduced with the same exact feature file, code and config file in this. more minimal zip file (lacking some folders that are not being referenced or used)

google_search__no_reproduce_socket_hang_up.zip

Allure-report.zip where, if you filter out all passing and failed TCs, you can see each feature file with >9 scenarios hits the 'socket hang up' at TC8,9,10,11 or12:
allure-report.zip

browser.reload() failing to reload the session when this was called after a failed test

From @nareshnayini on February 26, 2019 18:19

I am encountering issues when trying to use reload after every test when preceding test fails.

Environment:

  • WebdriverIO version: 4.13.2
  • Mode: WDIO Testrunner
  • If WDIO Testrunner, running sync/async: async
  • Node.js version: 10.5.0
  • NPM version: 6.1.0
  • Browser name and version: Chrome 69
  • Platform name and version: macOS 10.13.5
  • Additional wdio packages used (if applicable): * wdio-jasmine-framework

Describe the bug
When a test fails, browser.reload() function inside afterTest failing with the below mentioned error. So, browser session is not deleted and it's reloading with session session.

To Reproduce
Steps to reproduce the behavior:
WDIO config:
afterTest: () => {
browser.reload();
},
afterSession: async () => {
await browser.end().pause(1000);
},
after: async () => {
await browser.pause(1000);
},

Expected behavior
It is expected that, upon reload() call, user will be logged out from application and application relaunches.

Log
Error in onReload hook: "Error: Don't end the session manually. This will be done automatically.
at session("delete") - end.js:31:17
at init() - reload.js:40:23
at end() - reload.js:40:17
at screenshot() - saveScreenshot.js:52:17
at reload() - index.js:312:3"

I have looked into other tickets related to this issue but nowhere found the solution. Most of the tickets were closed saying they are inactive.

Copied from original issue: webdriverio/webdriverio#3634

Remove assumption of tab/window order back from browsers

From @mikesalvia on February 8, 2019 16:2

The code inclose.js assumes order is the order of creation and [0] is the "original" tab, this is not true and can cause race conditions when closing a new tab that is presented at [0] in the "windowsHandles()" return.

Environment (please complete the following information):

  • WebdriverIO version: 4.14.3
  • Mode: N/A
  • If WDIO Testrunner, running sync/async: N/A
  • Node.js version: N/A
  • NPM version: N/A
  • Browser name and version: IE 11
  • Platform name and version: macOS (Mojave)
  • Additional wdio packages used (if applicable): Lots

Config of WebdriverIO
N/A

Describe the bug
IE doesn't return tabs/windows in the order created this will cause issues with places that assume order (i.e. close.js)

To Reproduce
Not exactly easy as we need to wait for IE to give back the tabs in different orders

Expected behavior
A clear and concise description of what you expected to happen.

Log
N/A

Additional context
N/A

Please use the correct markdown

Copied from original issue: webdriverio/webdriverio#3531

Unable to use selectByVisibleText() on drop down menu values that contain &nbsp;

From @adamlemisch on December 29, 2016 16:14

The problem

When attempting to make a selection using selectByVisibleText() from a drop down menu who's values contain &nbsp's, the following error is received:

An element could not be located on the page using the given search parameters.
running chrome
Error: An element could not be located on the page using the given search parameters.
    at elementIdElement("4", "./option[normalize-space(.) = "A01 - NORTHWEST"]|./optgroup/option[normalize-space(.) = "A01 - NORTHWEST"]") - selectByVisibleText.js:33:22

Menu structure:
image

Commands attempted:
PageOnePage.area_drop_down.selectByVisibleText('A01&nbsp;-&nbsp;NORTHWEST');
PageOnePage.area_drop_down.selectByVisibleText('A01 - NORTHWEST');

Environment

  • WebdriverIO version: ^4.5.2
  • Node.js version: v7.2.1
  • Standalone mode or wdio testrunner: wdio
  • if wdio testrunner, running synchronous or asynchronous tests: synchronous
  • Additional wdio packages used (if applicable): N/A

Please let me know if more information is needed.

Copied from original issue: webdriverio/webdriverio#1795

webdriverio moveToObject()

The problem

When using the moveToObject() function. it seems that its not opening the dropdown menu of a page.

Environment

WebdriverIO version: 4.14.2
If WDIO Testrunner, running sync/async: async
Node.js version: v8.11.2
NPM version: 6.4.1
Browser name and version: Chrome Version 71.0.3578.98 (Official Build) (64-bit)
Platform name and version: MacOSX 10.13.6 (remotely)

Details

I am trying to simulate a mouse over on a bootstrap menu in a browser. the issue is that I'm not able to do a click command because the menu will only open if you hover the mouse pointer and when the time that you will try to click it. the menu disapear.

I can verify that the element is there because when using a click Command, it will open and close the menu. so when using the moveToObject() it doesn't have any error. only warning on the deprication and it will pass the test but it did not open the menu. Below is the code/function I created. I also did the actions command and touchAction but seems not working as well.

Link to Selenium/WebdriverIO logs

n/a

Code To Reproduce Issue [ Good To Have ]

async hover(locator) {
    const errorMsg = UNSUCCESSFULL_MESSAGE + locator;
    await this.executeWithErrorHandling(async () => {
      await this.browser.waitForExist(locator, 20000);
      await this.browser.moveToObject(locator);
    }, errorMsg);
    await this.pauseForInSeconds(1);
  }

how to get ELEMENT value in Standalone Mode

From @jiangyd on October 29, 2018 7:25

> var webdriverio = require('webdriverio');
undefined
> var options = { desiredCapabilities: { browserName: 'chrome' } };
undefined
> var client = webdriverio.remote(options);
undefined
> client.init().url("https://csos.cloudcare.cn")
{ state: 'pending' }
> var eleobject=client.element('/html/body/div[2]/header/div[2]/a[2]/input')
undefined
> console.log(eleobject)
{ state: 'fulfilled',
  value:
   { sessionId: '95a30dc18d91b93def35e58cc5cfd405',
     status: 0,
     value:
      { ELEMENT: '0.8181596695218141-1',
        'element-6066-11e4-a52e-4f735466cecf': '0.8181596695218141-1' },
     selector: '/html/body/div[2]/header/div[2]/a[2]/input' } }
undefined
> console.log(eleobject.value.value.ELEMENT)
TypeError: Cannot read property 'value' of undefined
    at repl:1:29
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:442:10)
    at emitOne (events.js:121:20)
    at REPLServer.emit (events.js:211:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)
> client.elementIdRect(client.element('/html/body/div[2]/header/div[2]/a[2]/input').value.ELEMENT)
TypeError: Cannot read property 'ELEMENT' of undefined
    at repl:1:88
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:442:10)
    at emitOne (events.js:121:20)
    at REPLServer.emit (events.js:211:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)

Copied from original issue: webdriverio/webdriverio#3027

No error screenshots are taken if mocha tests times out

From @perhenrikandersson on October 1, 2018 7:10

The problem

When running wdio tests with mocha no screenshots are taken if the mocha timeout is reached.

Environment

  • WebdriverIO version: master (I guess 4.13.2)
  • Node.js version: v8.11.2
  • Standalone mode or WDIO Testrunner: Wdio test runner
  • if wdio testrunner, running synchronous or asynchronous tests: syncronous
  • Additional wdio packages used (if applicable):
  • OS: Windows 10

Details

I used the wdio mocha examples to reproduce this.

Step-by-step:

  1. Set mochaOpts timeout to 60000
  2. Add a browser.waitForVisible('#nonexistingelement',70000); in your test
  3. Run tests using wdio wdio.conf.js command
    Expected: Mocha times out and a screenshot is saved
    Actual: Mocha times out and no screenshot is taken

If I instead set the mochaOpts timeout to 90000, the test will fail and a screenshot is taken since the mocha timeout is not reached.

Note: I had to run the tests from within the mocha folder using the "wdio wdio.conf.js" command since the command in the README.md didn't work for me (on a windows machine). Yes perhaps I should have written a bug on that too, but that was just not what I was after this time, and I didn't really have time to dig into that problem.

Link to Selenium/WebdriverIO logs

https://gist.github.com/perhenrikandersson/4e511e5c656bdc99406aecd17bae042d

Code To Reproduce Issue [ Good To Have ]

I used the wdio mocha examples:
https://github.com/webdriverio/webdriverio/tree/master/examples/wdio/mocha

I modified the wdio.conf.js since I don't have any grid running and I needed errorShots according to:
//hostname: '0.0.0.0', //port: 4444, port: '9515', path: '/', services: ['chromedriver'], screenshotPath: './errorShots/',

I also modified mocha.test.js to be able to reproduce the problem according to:
it('should have the right title - the fancy generator way', () => { browser.url('http://webdriver.io') // Next row is added by me and is expected to fail browser.waitForVisible('#nonexistingelement',70000); const title = browser.getTitle() assert.equal(title, 'WebdriverIO - WebDriver bindings for Node.js') })

Copied from original issue: webdriverio/webdriverio#2974

single quotes sometimes converted to double quotes?

From @worc on December 8, 2018 0:1

i don't even know on this one. i have an attribute selector with characters that break the underlying query (spaces and slashes in this case), so i wrapped the selector in double quotes and the full query in single quotes:

browser.click('input[name="enable_Selector With Spaces"][value=yes]')

and periodically the test would error out with this message:

An element could not be located on the page using the given search parameters.
Error: An element could not be located on the page using the given search parameters.
at click("input[name="enable_Selector With Spaces"][value=yes]") - at element("input[name="enable_Selector With Spaces"][value=yes]") - click.js:12:17

which at first glance seems like the single quotes around the full query are being converted to double quotes? i wasn't sure how to verify that, so i did the next best thing and changed the single quotes to backticks:

browser.click(`input[name="enable_Selector With Spaces"][value=yes]`)

at that point the error cleared up. but just to verify the issue, i switched the backticks back to single quotes, but the error no longer occurs. i'm thinking i probably just missed something juggling all those quotes and brackets, but figured i'd at least write down the weird thing i saw in case someone else encounters it.

"webdriverio": "^4.14.0",
"wdio-cucumber-framework": "^2.2.7",
"wdio-chromedriver-service": "^0.1.3",

Copied from original issue: webdriverio/webdriverio#3109

unable to provide/set element id properly to selectPickerWheelValue

From @LayMuiToh on February 25, 2019 12:24

[//]: # NOTE: This repository only maintains packages that are listed in the Readme. Please make sure that your issue is directly caused by one of these packages and if not file an issue in the correct 3rd party package repository.

Environment (please complete the following information):

  • **WebdriverIO version:**v.4.14.1

  • Mode: [Standalone mode or WDIO Testrunner: wdio testrunner

  • **If WDIO Testrunner, running sync/async:**sync

  • Node.js version: v10.15.1

  • **NPM version:**6.4.1

  • **Browser name and version:**NA (mobile native)

  • Platform name and version: iOS 10.3.1

  • Additional wdio packages used (if applicable): [e.g. @wdio/spec reporter, @wdio/selenium-standalone service]

Config of WebdriverIO

exports.config = {

    //
    // ==================
    // Specify Test Files
    // ==================
    // Define which test specs should run. The pattern is relative to the directory
    // from which `wdio` was called. Notice that, if you are calling `wdio` from an
    // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
    // directory is where your package.json resides, so `wdio` will be called from there.
    //
    specs: [
        'test/spec/**/**'
    ],
    // define specific suites
    suites: {
        
    // Patterns to exclude.
    exclude: [
        // 'path/to/excluded/files'
    ],
    //
    // ============
    // Capabilities
    // ============
    // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
    // time. Depending on the number of capabilities, WebdriverIO launches several test
    // sessions. Within your capabilities you can overwrite the spec and exclude options in
    // order to group specific specs to a specific capability.
    //
    // First, you can define how many instances should be started at the same time. Let's
    // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
    // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
    // files and you set maxInstances to 10, all spec files will get tested at the same time
    // and 30 processes will get spawned. The property handles how many capabilities
    // from the same test should run tests.
    //
    maxInstances: 1,
    //
    // If you have trouble getting all important capabilities together, check out the
    // Sauce Labs platform configurator - a great tool to configure your capabilities:
    // https://docs.saucelabs.com/reference/platforms-configurator
    //
    capabilities: [{
        // maxInstances can get overwritten per capability. So if you have an in-house Selenium
        // grid with only 5 firefox instances available you can make sure that not more than
        // 5 instances get started at a time.
        browserName: '',
        appiumVersion: '1.10.1',
        platformVersion: '10.3.1',
        platformName: 'iOS',
        deviceName: 'iPhone Simulator',
        udid: '03AE5EA1-DB79-40F2-A365-677B710B5837',
        app: '/Users/tohlaymui/Library/Developer/Xcode/DerivedData/performance_analyst-exzmnafxweexfvdwtpbkbseqplub/Build/Products/Debug-iphonesimulator/performance_analyst.app',
        bundleId: 'ai.telepathy.performanceanalyst-dev',
        automationName: 'XCUITests',
        noReset: false,
        usePrebuiltWDA: true,
        newCommandTimeout: 7000,
        printPageSourceOnFindFailure: true,
       
    }],        
    //
    // ===================
    // Test Configurations
    // ===================
    // Define all options that are relevant for the WebdriverIO instance here
    //
    // By default WebdriverIO commands are executed in a synchronous way using
    // the wdio-sync package. If you still want to run your tests in an async way
    // e.g. using promises you can set the sync option to false.
    sync: true,
    //
    // Level of logging verbosity: silent | verbose | command | data | result | error
    logLevel: 'verbose',
    //
    // Enables colors for log output.
    coloredLogs: true,
    //
    // Warns when a deprecated command is used
    deprecationWarnings: true,
    //
    // If you only want to run your tests until a specific amount of tests have failed use
    // bail (default is 0 - don't bail, run all tests).
    bail: 0,
    //
    // Saves a screenshot to a given path if a command fails.
    screenshotPath: './errorShots/',
    //
    // Set a base URL in order to shorten url command calls. If your `url` parameter starts
    // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
    // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
    // gets prepended directly.
    //baseUrl: 'http://localhost',
    //
    // Default timeout for all waitFor* commands.
    waitforTimeout: 10000,
    //
    // Default timeout in milliseconds for request
    // if Selenium Grid doesn't send response
    connectionRetryTimeout: 90000,
    //
    // Default request retries count
    connectionRetryCount: 3,
    //
    // Initialize the browser instance with a WebdriverIO plugin. The object should have the
    // plugin name as key and the desired plugin options as properties. Make sure you have
    // the plugin installed before running any tests. The following plugins are currently
    // available:
    // WebdriverCSS: https://github.com/webdriverio/webdrivercss
    // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
    // Browserevent: https://github.com/webdriverio/browserevent
    plugins: {
        'wdio-screenshot': {},
        'wdio-native-app-compare': {
            baselineFolder: '.dist/image-compare/baseline',
            screenshotPath: '.dist/image-compare/screenshots',
            autoSaveBaseline: true,
            blockOutStatusBar: true,
            blockOutIphoneXBottomBar: true,
            blockOutNavigationBar: true,
            debug: true,

            // See Options for more options
            //..
          },
    },
    //
    // Test runner services
    // Services take over a specific job you don't want to take care of. They enhance
    // your test setup with almost no effort. Unlike plugins, they don't add new
    // commands. Instead, they hook themselves up into the test process.
    services: ['appium'],
    appium: {
        args: {
            address: '127.0.0.1',
            commandTimeout: '11000',
            sessionOverride: true,
            debugLogSpacing: true,
            platformVersion: '10.3.1',
            platformName: 'iOS',
            showIosLog: true,
            deviceName: 'iPhone 6s',
            nativeInstrumentsLib: true,
            app: '/Users/tohlaymui/Library/Developer/Xcode/DerivedData/performance_analyst-exzmnafxweexfvdwtpbkbseqplub/Build/Products/Debug-iphonesimulator/performance_analyst.app',
        },
    },
    // Default port for Appium
    port: 4723,
    maxInstances: 1,

    //
    // Framework you want to run your specs with.
    // The following are supported: Mocha, Jasmine, and Cucumber
    // see also: http://webdriver.io/guide/testrunner/frameworks.html
    //
    // Make sure you have the wdio adapter package for the specific framework installed
    // before running any tests.
    framework: 'mocha',
    //
    // Test reporter for stdout.
    // The only one supported by default is 'dot'
    // see also: http://webdriver.io/guide/reporters/dot.html
    // reporters: ['dot'],
    //
    // Options to be passed to Mocha.
    // See the full list at http://mochajs.org/
    mochaOpts: {
        ui: 'bdd',
        timeout:99999999,
        compilers: ['js:babel-register'],
       
    },
    // =====
    // Hooks
    // =====
    // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
    // it and to build services around it. You can either apply a single function or an array of
    // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
    // resolved to continue.
    //
    /**
     * Gets executed once before all workers get launched.
     * @param {Object} config wdio configuration object
     * @param {Array.<Object>} capabilities list of capabilities details
     */
    onPrepare: function (config, capabilities) {
    },
    /**
     * Gets executed just before initialising the webdriver session and test framework. It allows you
     * to manipulate configurations depending on the capability or spec.
     * @param {Object} config wdio configuration object
     * @param {Array.<Object>} capabilities list of capabilities details
     * @param {Array.<String>} specs List of spec file paths that are to be run
     */
    beforeSession: function (config, capabilities, specs) {
       
    },
    /**
     * Gets executed before test execution begins. At this point you can access to all global
     * variables like `browser`. It is the perfect place to define custom commands.
     * @param {Array.<Object>} capabilities list of capabilities details
     * @param {Array.<String>} specs List of spec file paths that are to be run
     */
    before: function (capabilities, specs) {
        var chai = require('chai');
        global.expect = chai.expect;
        chai.Should();
    },
    /**
     * Hook that gets executed before the suite starts
     * @param {Object} suite suite details
     */
    beforeSuite: function (suite) {
    },
    /**
     * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
     * beforeEach in Mocha)
     */
    beforeHook: function () {
    },
    /**
     * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
     * afterEach in Mocha)
     */
    afterHook: function () {
    },
    /**
     * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
     * @param {Object} test test details
     */
    beforeTest: function (test) {
    },
    //
    /**
     * Runs before a WebdriverIO command gets executed.
     * @param {String} commandName hook command name
     * @param {Array} args arguments that command would receive
     */
    beforeCommand: function (commandName, args) {
    },
    /**
     * Runs after a WebdriverIO command gets executed
     * @param {String} commandName hook command name
     * @param {Array} args arguments that command would receive
     * @param {Number} result 0 - command success, 1 - command error
     * @param {Object} error error object if any
     */
    afterCommand: function (commandName, args, result, error) {
    },
    /**
     * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
     * @param {Object} test test details
     */
    afterTest: function (test) {
    },
    /**
     * Hook that gets executed after the suite has ended
     * @param {Object} suite suite details
     */
    afterSuite: function (suite) {
    },
    /**
     * Gets executed after all tests are done. You still have access to all global variables from
     * the test.
     * @param {Number} result 0 - test pass, 1 - test fail
     * @param {Array.<Object>} capabilities list of capabilities details
     * @param {Array.<String>} specs List of spec file paths that ran
     */
    after: function (result, capabilities, specs) {
    },
    /**
     * Gets executed right after terminating the webdriver session.
     * @param {Object} config wdio configuration object
     * @param {Array.<Object>} capabilities list of capabilities details
     * @param {Array.<String>} specs List of spec file paths that ran
     */
    afterSession: function (config, capabilities, specs) {
        
    },
    /**
     * Gets executed after all workers got shut down and the process is about to exit.
     * @param {Object} exitCode 0 - success, 1 - fail
     * @param {Object} config wdio configuration object
     * @param {Array.<Object>} capabilities list of capabilities details
     */
    onComplete: function (exitCode, config, capabilities) {
    },
    //
    // Cucumber specific hooks
    beforeFeature: function (feature) {
    },
    beforeScenario: function (scenario) {
    },
    beforeStep: function (step) {
    },
    afterStep: function (stepResult) {
    },
    afterScenario: function (scenario) {
    },
    afterFeature: function (feature) {
    }
};

Describe the bug
An unknown server-side error occurred while processing the command. Original error: Element id is expected to be set for selectPickerWheelValue method

code snippet to call the selectPickerWheel:
browser.execute('mobile: selectPickerWheelValue',
{ element: MoreFilters.picker.ELEMENT, order: 'next', offset: 0.5});

import Page from './Page';

const SELECTORS = {
   
    IOS_PICKERWHEEL: '~Picker',
    DONE: '~Done',
   
};

class MoreFilters extends Page {

    /* 
    ** Define elements
    */
    
    get picker()  { return $(SELECTORS.IOS_PICKERWHEEL); }
    get done()  { return $(SELECTORS.DONE); }

 it('should able to tap on the More Filters and go to the More Filters Page', () => {
        Results.morefilters.waitForVisible() &&
        Results.morefilters.click();

        if (MoreFilters.filter_by_date.waitForVisible()) {
          const filter_by_date_x = browser.getLocation('~Filter by Date', 'x');
          const filter_by_date_y = browser.getLocation('~Filter by Date', 'y');
          browser.execute('mobile: tap', 
          { element: MoreFilters.filter_by_date, x: filter_by_date_x, y: filter_by_date_y});
          
          if (MoreFilters.picker.waitForVisible()) {
            browser.execute('mobile: selectPickerWheelValue', 
            { element: MoreFilters.picker.ELEMENT, order: 'next', offset: 0.5});
 
            MoreFilters.done.waitForVisible() && 
            MoreFilters.done.click();
          }
        } 
    });
      

To Reproduce
Steps to reproduce the behavior:

[Include code or an example repository that can easily be set up]

Expected behavior
it should able to select the picker UI element value.

Log
If applicable, add logs to help explain your problem.
https://gist.github.com/LayMuiToh/2a36e54b6832394ee3daa9e0557307f4

Additional context
Add any other context about the problem here.

Please use the correct markdown

Copied from original issue: webdriverio/webdriverio#3617

Problem with getValue and Appium 1.8.0 on Android

From @ianrenauld on May 8, 2018 20:18

The problem

This is very similar to #2574. With Appium 1.8.0 I cannot getValue from an <input> field on Android (Hybrid App - it works fine on iOS). We receive no RESULT, but if I switch to the older, non-W3C calls, it works. The error from Appium seems to be "unknown command", but we already check for this value. The difference from before (#2574) is that this call seems to timeout, so I don't think we ever get to the check for unknown command.

Environment

  • WebdriverIO version: 4.12.0
  • Node.js version: 8.11.1
  • wdio testrunner, running synchronously
  • Appium 1.8.0

Details + Logs

Here is the log with WebdriverIO 4.9.9 (uses non-W3C calls):

[14:48:29]  COMMAND     POST     "/wd/hub/session/aac6fead-ac07-4d34-9799-5ca20ffa2103/element"
[14:48:29]  DATA                {"using":"name","value":"username"}
[14:48:29]  RESULT              {"ELEMENT":"0.7004955660714918-3"}
[14:48:29]  COMMAND     GET      "/wd/hub/session/aac6fead-ac07-4d34-9799-5ca20ffa2103/element/0.7004955660714918-3/attribute/value"
[14:48:29]  DATA                {}
[14:48:29]  RESULT              "toto"

Here is the log with WebdriverIO 4.12.0 (uses W3C calls):

[14:55:57]  COMMAND     POST     "/wd/hub/session/9c667f8e-d46b-4d32-bb0b-75af98e51557/element"
[14:55:57]  DATA                {"using":"name","value":"username"}
[14:55:57]  RESULT              {"ELEMENT":"0.13486487362687805-3"}
[14:55:57]  COMMAND     GET      "/wd/hub/session/9c667f8e-d46b-4d32-bb0b-75af98e51557/element/0.13486487362687805-3/property/value"
[14:55:57]  DATA                {}

After this last line, nothing happens until the test timeout. From appium.log:

[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/ce7ca87d-6679-4802-ad1c-48196811f466/element/0.8170637210466369-3/property/value] to [GET http://127.0.0.1:8000/wd/hub/session/7ea27f9476f8927b9d13a1fb22201ad4/element/0.8170637210466369-3/property/value] with body: {}
[JSONWP Proxy] Got unexpected response: unknown command: session/7ea27f9476f8927b9d13a1fb22201ad4/element/0.8170637210466369-3/property/value

I tried playing around with the utilities.js helper file, but the isUnknownCommand method already checks for "unknown command". My feeling is that this method is never actually called. I think there is a failure in waiting for the response in the RequestHandler.js file. Unfortunately, my understanding of what is going on in there is too limited for me to find a solution...

Code To Reproduce Issue

For any <input> element in an Hybrid app, just do getValue() on it.

Copied from original issue: webdriverio/webdriverio#2726

switchTab not working

From @tvnking on March 6, 2019 1:57

I can't switch tab on iOS. my code:
popupO365 = browser.windowHandles().value.filter((handle) => handle !== loginScreen)[0];
browser.switchTab(popupO365)
p/s: WebdriverIOs version 4.14.3

Copied from original issue: webdriverio/webdriverio#3685

How to extend Element class method in TypeScript using webdriverio?

From @draganrakas on March 12, 2019 15:45

Stack: TypeScript, WDIO, Cucumber

We are having an issue with the click() functionality not working on buttons in SauceLabs only, and on FireFox only. We tested other combinations (local, CI, Docker, etc.) and our tests work on both FireFox and Chrome for all of those combinations. However, on SauceLabs, clicking a button in FireFox is very flaky.

We have tested a JavaScript workaround that works, on SauceLabs on FireFox, and as a result, we would like the element click() method to behave differently depending if the browser capability is either chrome or firefox.

To do this, we would like to extend the WebDriver Element, and override the click method with our own. Basically, use super.click() for chrome, and our own click for firefox.

Currently, our BasePage exports this, which is just a typedef that the page objects use:
export type WDIOElement = WebdriverIO.Client<WebdriverIO.RawResult<WebdriverIO.Element>>

Instead of this, we would like to create a WDIOElement definition that implements the WebdriverIO.Client<WebdriverIO.RawResult<WebdriverIO.Element>> interface, re-implements click() and export that instead.

Is this even possible? What would be the recommended way to do this?
If this is pretty bad practice, is there something better we could do?

Thanks!

Copied from original issue: webdriverio/webdriverio#3719

Browser.chooseFile() sets the file to being modified in the future

From @rsshilli on March 1, 2019 21:25

Environment:

  • WebdriverIO version: 4.4.0
  • Mode: Standalone mode (packaged with Chimp)
  • Node.js version: 8.10.0
  • NPM version: 6.0.1
  • Browser name and version: Chrome 72.0.3626.119
  • Platform name and version: Windows 10
  • Additional wdio packages used (if applicable):

Config of WebdriverIO
I'm using WebdriverIO through Chimp. My webdriverio configuration is:

  webdriverio: {
    logLevel: "verbose",
    logOutput: "build/test/report",
    deprecationWarnings: false,
    coloredLogs: !isBuildSystem,
    waitforTimeout: (isBuildSystem ? 120 : 30)*1000,
  },

Describe the bug
When I use browser.chooseFile(), Chrome accepts the file properly and uploads it. Using the File API (https://www.w3.org/TR/FileAPI/) the code on my webpage is getting the file name, size, and the last modified date to show it in the UI after it's been uploaded.

When I upload a file that was last modified yesterday, the file is uploaded as having been last modified 5 hours from now! Woah, it's like a glimpse into the future! Except I'm pretty sure it's because I'm in UTC-5.

After looking into the Chrome logs, I see that my original file is not the one sent to Chrome, but instead the file is being copied to a new location and being sent from there:

[15:49:40]  COMMAND	POST 	 "/wd/hub/session/fa5b1d54954b4ee5f61be6b445c83c9d/file"
[15:49:40]  DATA		{"file":"[base64] 38744 bytes"}
[15:49:40]  RESULT		"C:\\Users\\ryans\\AppData\\Local\\Temp\\scoped_dir30340_24649\\upload30340_15490\\SampleUpload2.pdf"

That's weird. When I look at that file, it's also in the future! Note above that I sent the file at 3:49pm

C:\> dir C:\Users\ryans\AppData\Local\Temp\scoped_dir30340_24649\upload30340_15490\SampleUpload2.pdf
 Volume in drive C is Windows
 Volume Serial Number is 407E-A66F

 Directory of C:\Users\ryans\AppData\Local\Temp\scoped_dir30340_24649\upload30340_15490

03/01/2019  08:49 PM            29,887 SampleUpload2.pdf
               1 File(s)         29,887 bytes
               0 Dir(s)  47,966,064,640 bytes free

I don't know how this magic is happening. Is it possible that the file doesn't need to be copied? Or maybe that the last modified date should be kept, as opposed to being set to the current time in UTC?

To Reproduce

Here's my code to use Webdriver.io to upload the file:

    let filePath = path.join(__dirname, "..", "files", fileName);
    browser.chooseFile("#uploadDocumentButton", filePath);

Here's a sample of the code in the browser that gets the date:

  let input = $("#" + event.target.id)[0];

  if (input.files) {
    let file = input.files[0];
    fileData.fileName = file.name;
    fileData.size = file.size;
    fileData.lastModified = file.lastModified;

Expected behavior
I would expect the file's original last modified date to be what I see in my JavaScript running in Chrome.

Log
Chrome log is included in the bug description above.

Additional context
My code in the browser works fine when I choose the file manually.

Copied from original issue: webdriverio/webdriverio#3665

SauceLabs URL incorrect in v4.14.3

The problem

In PR #9 a change was made to allow you to override the host URL for Sauce Labs. Unfortunately in that change they modified the backticks to be double-quotes.

I'm leaving most of this issue empty, because I plan on submitting a PR for this very soon. I just want to log it in case someone else runs into this issue, or I don't get time to make the fix (should be really small though).

FYI: If you use the sauce service, along with setting sauceConnect to true, it overrides the bug so it doesn't appear.

Environment

  • WebdriverIO version: 4.14.3
  • Node.js version:
  • Standalone mode or wdio testrunner: testrunner
  • if wdio testrunner, running synchronous or asynchronous tests: sync
  • Additional wdio packages used (if applicable): wdio-sauce-service

Relevant logs for searchability:

[1;30m[12:45:01] �[0m �[0;35mCOMMAND    �[0mPOST     "/$%7BgetSauceEndpoint(capabilities.region)%7D:443/wd/hub/session"
�[1;30m[12:45:01] �[0m �[0;33mDATA      �[0m{"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"browserName":"chrome","platform":"macOS 10.14","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.14.3","name":"webdriverio"}}}
ERROR: getaddrinfo EAI_AGAIN ondemand.:443
chrome.macos10_14
    at new RuntimeError (\automated-tests\node_modules\webdriverio\build\lib\utils\ErrorHandler.js:143:12)
    at Request._callback (\automated-tests\node_modules\webdriverio\build\lib\utils\RequestHandler.js:342:43)
    at self.callback (\automated-tests\node_modules\request\request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (\automated-tests\node_modules\request\request.js:881:8)
    at emitOne (events.js:121:20)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)

Calling browser.timeouts() for Safari tests in a hook errors and results in rest of hook not executing

From @jochakovsky on October 31, 2018 1:0

Environment (please complete the following information):

  • WebdriverIO version: 4.14.0
  • Mode: WDIO Testrunner
  • If WDIO Testrunner, running sync/async: sync
  • Node.js version: 8.11.2
  • NPM version: 6.4.1
  • Browser name and version: 12.0.1 (13606.2.104.1.2)
  • Platform name and version: macOS 10.13.6
  • Additional wdio packages used (if applicable):

Config of WebdriverIO
https://github.com/jochakovsky/webdriverio-browser-timeouts-bug

Describe the bug
Calling browser.timeouts() for Safari tests in a hook throws the following error:

Error: Remote end send an unknown status code.
    at timeouts("implicit", 15000) - index.js:263:37
    at init() - runner.js:235:55

For me, I put the call to browser.timeouts() in the before hook, and this error prevented the rest of the hook from executing. In my real project, there are some critical commands run afterwards in the same hook. Since those were skipped, my tests would fail for very hard-to-debug reasons.

No issues setting timeouts in Chrome or Firefox.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
Any of the following:

  • Correctly setting the timeout
  • A clear error message that it is not possible to set the timeout in this browser referencing the line number of the browser.timeouts() call, and the WDIO test runner exits with a failure code
  • A clear error message that it is not possible to set the timeout in this browser referencing the line number of the browser.timeouts() call, and the WDIO test runner continues executing the hook

Copied from original issue: webdriverio/webdriverio#3029

No way to shut off screenshots on error.

From @pmerwin on December 30, 2017 16:55

The problem

There is no way to shut off taking a screenshot on error. We are using Try/Catch and expect errors, and do not need screenshots when that happens, as this slows down the test, and creates more possibility for something to go wrong.

Environment

  • WebdriverIO version: "webdriverio": "^4.9.9",
  • Node.js version: v6.10.3
    *testrunner
  • if wdio testrunner, running synchronous or asynchronous tests: sync
  • Additional wdio packages used (if applicable):

Details

I want to set take screenshot to false inside of try blocks, as when we get an error in a try block, wdio is still taking a screenshot. I want to turn this off/on in my function called from my tes.t

Link to Selenium/WebdriverIO logs

AVailable if needed

Code To Reproduce Issue [ Good To Have ]

available if needed, I have posted on gitter chat for any suggestions and have not received a response. Thanks in advance!

"// Saves a screenshot to a given path if a command fails.
screenshotPath: config.wdio.errors,
//

Anyone know how to shut this off at spec/function level. We use Try/Catch and don't need a screen shot when an error is expected. The only option I see to change is the above. Tried setting this to null, did not work.

Any help? Just wondering what value to set in a local function try/catch that will shut off snapshots on error as I am expecting an error and do not need a snapshot. I thought if the error happened in the try block it should not trigger a snapshot but it does."

Copied from original issue: webdriverio/webdriverio#2529

browser.waitForVisible(...) returns timeout error on certain situation

Hi all,
I am wondering how wdio v4 detects if certain element is visible when I test with browser.waitForVisible().

I have a reproducible code.
And there is explanation on readme.md.

Simply, if there is a component that has only a child element that has position:absolute, browser.waitForVisible() not working (timeout) even if it's actually visible on the browser.

I guess it's failing because <child-component> has 0 height.

This failure is expected behavior?

On readme.md, there is 'The solutions I have found so far' section.
Please let me know this is correct approach.

note 1: I am testing with shadowDom. I have installed wdio-webcomponents.
note 2: I am using wdio 4 because of CucumberJs.

** The key point is the below code. **

// step.js
Then('I should see form', () => {
    const path = 'e2e-app child-component';
    browser.waitForVisible(path, 10000);
});

// child-component.html
<style>
    form {
      /* 'fixed' will be also failing */
      position: absolute; 
    }
</style>
    
<form>
    <label for="someInput">Your name :</label>
    <input type="text" id="someInput">
</form>

Environment (please complete the following information):

  • **WebdriverIO: 4.13.2
  • Mode: : I actually don't know. I am running by ./node_modules/.bin/wdio wdio.e2e.conf.js. Is this runner mode?
  • Node.js version: 8.16.0
  • NPM version: 6.4.1
  • Browser name and version: Chrome 75.0
  • Platform name and version: OSX Mojave 10.14.5
  • Additional wdio packages used (if applicable):
  • selenium-standalone: 6.16.0
  • wdio-chromedriver-service: 0.1.5
  • wdio-cucumber-framework: 2.2.8
  • wdio-dot-reporter: 0.0.10
  • wdio-json-reporter: 0.4.0
  • wdio-junit-reporter: 0.0.2
  • wdio-multiple-cucumber-html-reporter: 0.3.3
  • wdio-selenium-standalone-service: 0.0.12
  • wdio-spec-reporter: 0.1.5
  • wdio-sync: 0.7.3
  • wdio-webcomponents: 1.1.0

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.