Skip to content

grabValueFrom returns empty array on firefox and new codeceptjs version #1524

Closed

Description

@yogainalift

Getting empty array for firefox when trying to grabValueFrom element

Additionally chrome returns array of 1 element even though there was only 1 result.

Console output with --verbose flag enabled (relevant part for firefox)

Emitted | step.passed (I wait 2)
Emitted | step.finish (I wait 2)
Emitted | step.start (I grab value from "#exampleFormControlSelect1")
I grab value from "#exampleFormControlSelect1"
Emitted | step.passed (I grab value from "#exampleFormControlSelect1")
Emitted | step.finish (I grab value from "#exampleFormControlSelect1")
[]
Emitted | test.passed ([object Object])
Emitted | test.finish ([object Object])

Reproduction test

Feature('CodeceptJS demo');

Scenario('check Welcome page on site', async (I) => {
  I.amOnPage('https://getbootstrap.com/docs/4.0/components/forms/');
  I.waitForElement('#exampleFormControlSelect1');
  I.selectOption('#exampleFormControlSelect1', '5');
  I.wait(2);
  const value = await I.grabValueFrom('#exampleFormControlSelect1');
  console.log(value);
});

Version Details

  • CodeceptJS version: 2.0.6
  • NodeJS Version: 10.12.0
  • Operating System: linux
  • WebDriver version: 5.6.2
  • selenium standalone: 3.141.59
  • geckodriver: v0.24.0
  • firefox: 60.3.0esr
  • chromedriver: 2.46
  • chrome: 72.0.3626.96

Configuration file:

const outputFolder = './output';

exports.config = {
  tests: './tests.js',
  output: './output',
  helpers: {
    WebDriver: {
      url: 'http://localhost:4200',
      browser: 'firefox',
      windowSize: '2560x1440',
      restart: false,
      desiredCapabilities: {
        'moz:firefoxOptions': {
          args: [
            '-headless',
          ],
        },
      },
      // Might cause issues, remove if it does.
      timeouts: {
        script: 60000,
        pageLoad: 10000,
      },
      waitForTimeout: 10000,
      coloredLogs: true,
    },
    Mochawesome: {},
  },

  include: {
    I: './steps_file.js',
  },
  bootstrap: null,
  name: 'testcjs',

  multiple: {
    headless: {
      browsers: [
        {
          browser: 'firefox',
        },
        {
          browser: 'chrome',
          desiredCapabilities: {
            chromeOptions: {
              args: [
                '--headless',
                '--disable-gpu',
                '--window-size=1920,1080',
              ],
            },
          },
        },
      ],
    },
    headed: {
      browsers: [
        {
          browser: 'chrome',
        },
        {
          browser: 'firefox',
          desiredCapabilities: {
            'moz:firefoxOptions': {
              args: [],
            },
          },
        },
      ],
    },
  },

  mocha: {
    reporterOptions: {
      'codeceptjs-cli-reporter': {
        stdout: '-',
        options: {
          verbose: true,
          steps: false,
          debug: true,
        },
      },
      mochawesome: {
        stdout: '-',
        options: {
          enableCharts: true,
          autoOpen: false,
          json: false,
          reportFilename: 'result',
          quiet: false,
          reportDir: outputFolder,
          inlineAssets: true,
          reportPageTitle: 'E2E Test Reports',
          reportTitle: `Test Results`,
        },
      },
      'mocha-junit-reporter': {
        stdout: `${outputFolder}/console.log`,
        options: {
          mochaFile: `${outputFolder}/result.xml`,
        },
      },
    },
  },
};

Activity

  1. kobenguyent commented on Feb 25, 2019

    @kobenguyent
    Collaborator
    CodeceptJS v2.0.4
    Using test root "/Users/trung.nguyen/Desktop/tests"
    
    CodeceptJS demo --
      check Welcome page on site @test
        I am on page "https://getbootstrap.com/docs/4.0/components/forms/"
        I wait for element "#exampleFormControlSelect1"
        I select option "#exampleFormControlSelect1", "5"
        I wait 2
        I grab value from "#exampleFormControlSelect1"
    []
      ✔ OK in 3508ms
    

    was there since 2.0.4

  2. kobenguyent commented on Feb 25, 2019

    @kobenguyent
    Collaborator

    Found out this is due to deprecated method, I'll create a PR to fix this.

  3. yogainalift commented on Apr 1, 2019

    @yogainalift
    Author

    Hey PeterNgTr,

    Thanks for trying to solve this issue unfortunately I can still reproduce this.

    According to https://webdriver.io/docs/api/element/getValue.html the return value should be a string and not an array.

    This is an issue when trying to run tests suits for multiple browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions