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);
});
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`,
},
},
},
},
};
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
Found out this is due to deprecated method, I'll create a PR to fix this.
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.
Most helpful comment
Found out this is due to deprecated method, I'll create a PR to fix this.