question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebDriver 5: I.seeInField fails in Firefox: Cannot read property 'indexOf' of null

See original GitHub issue

It doesn’t fail with WebDriver 4. If you have WebDriver 5 and:

  • Selenium server <= 3.8.1 started with the option -enablePassThrough false, then test passes.
  • latest Selenium server, then test fails.

So possible workaround for Firefox is downgrade of WebDriver to ver. 4 or downgrade to Selenium server 3.8.1 (the last version which provides -enablePassThrough false).

Chrome isn’t affected in any configuration.

What are you trying to achieve?

I.seeInField("#search_input_react", "WebDriver")

What do you get instead?

Provide console output if related. Use --verbose mode for more details.

$ codeceptjs run My_test.js --profile firefox --verbose
2019-03-11T19:15:51.487Z DEBUG @wdio/config: @wdio/sync not found, running tests asynchronous
CodeceptJS v2.0.7
Using test root "/home/mira/workspace/mycodeceptjs/tests/seeinfield"
Helpers: WebDriver
Plugins: screenshotOnFail

My --
    [1] Starting recording promises
    Emitted | suite.before ([object Object])
  One
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "https://codecept.io/quickstart")
    Emitted | step.after (I am on page "https://codecept.io/quickstart")
    Emitted | step.before (I fill field "#search_input_react", "WebDriver")
    Emitted | step.after (I fill field "#search_input_react", "WebDriver")
    Emitted | step.before (I see in field "#search_input_react", "WebDriver")
    Emitted | step.after (I see in field "#search_input_react", "WebDriver")
    Emitted | step.start (I am on page "https://codecept.io/quickstart")
    I am on page "https://codecept.io/quickstart"
    Emitted | step.passed (I am on page "https://codecept.io/quickstart")
    Emitted | step.finish (I am on page "https://codecept.io/quickstart")
    Emitted | step.start (I fill field "#search_input_react", "WebDriver")
    I fill field "#search_input_react", "WebDriver"
    Emitted | step.passed (I fill field "#search_input_react", "WebDriver")
    Emitted | step.finish (I fill field "#search_input_react", "WebDriver")
    Emitted | step.start (I see in field "#search_input_react", "WebDriver")
    I see in field "#search_input_react", "WebDriver"
    [1] Error | TypeError: Cannot read property 'indexOf' of null
    Emitted | step.failed (I see in field "#search_input_react", "WebDriver")
    Emitted | step.finish (I see in field "#search_input_react", "WebDriver")
    [1] Error | TypeError: Cannot read property 'indexOf' of null
    [1] Starting <teardown> session
    Emitted | test.failed ([object Object])
    Emitted | test.finish ([object Object])
    [1] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, saving screenshot
 › Screenshot has been saved to /home/mira/workspace/mycodeceptjs/tests/seeinfield/output/One.failed.png
  ✖ FAILED in 8903ms

    [2] Starting recording promises
    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

-- FAILURES:

  1) My
       One:
     Cannot read property 'indexOf' of null
  
  Scenario Steps:
  
  - I.seeInField("#search_input_react", "WebDriver") at Test.Scenario (My_test.js:6:7)
  - I.fillField("#search_input_react", "WebDriver") at Test.Scenario (My_test.js:5:7)
  - I.amOnPage("https://codecept.io/quickstart") at Test.Scenario (My_test.js:4:7)
  
  TypeError: Cannot read property 'indexOf' of null
      at Object.comparator (/home/mira/workspace/mycodeceptjs/node_modules/codeceptjs/lib/assert/include.js:16:23)
      at InclusionAssertion.assert (/home/mira/workspace/mycodeceptjs/node_modules/codeceptjs/lib/assert.js:36:36)
      at browser.getElementAttribute.then.res (/home/mira/workspace/mycodeceptjs/node_modules/codeceptjs/lib/helper/WebDriver.js:2159:151)
      at process._tickCallback (internal/process/next_tick.js:68:7)


  FAIL  | 0 passed, 1 failed   // 14s
    Emitted | global.result ([object Object])
    Emitted | global.after ([object Object])

Provide test source code if related

Scenario("One", (I) => {
    I.amOnPage("https://codecept.io/quickstart");
    I.fillField("#search_input_react", "WebDriver");
    I.seeInField("#search_input_react", "WebDriver");
});

Details

  • CodeceptJS version: 2.0.7
  • NodeJS Version: 10.15.1
  • Operating System: Ubuntu 18.10
  • WebDriverIO: 5.7.2
  • Configuration file:
exports.config = {
    tests: "./*_test.js",
    output: "./output",
    helpers: {
        WebDriver: {
            url: "http://localhost",
            "browser": process.profile || "chrome",
        }
    },
    include: {
        I: "./steps_file.js"
    },
    bootstrap: null,
    mocha: {},
    name: "seeinfield"
};

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
schmunk42commented, Jun 5, 2019

We had a similar issue, while manipulating values of inputs with JavaScript with json-editor, our tests failed since upgrading to Firefox Selenium 3.x (https://travis-ci.org/json-editor/json-editor/builds/541217140#L596)

From looking through the CodedeptJS source code I think I.seeInField really looks at the HTML-source and since there’s no value attribute it fails. In contrast to grabValueFrom or waitForValue which selects the element from the DOM and then retrieves value from it (via JavaScript)

Example:

    I.waitForValue("[name='root[0][location][city]']", 'Stuttgart');
    // this does not work --> I.seeInField("[name='root[0][location][city]']", 'Stuttgart');

https://github.com/json-editor/json-editor/commit/144393e148b8fd90e8683e44f937fcb5e76d0f81

0reactions
miraocommented, Dec 6, 2019

It works for me with CodeceptJS 2.3.6 and WebDriverIO@5.16.13

  • Browsers

    • Google Chrome 78.0.3904.108
    • Mozilla Firefox 70.0.1
  • Selenium:

    • Server: 3.141.59
    • Chrome webdriver: 78.0.3904.105
    • Firefox webdriver: 0.26.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

WebDriver 5: I.seeInField fails in Firefox: Cannot read property ...
It doesn't fail with WebDriver 4. If you have WebDriver 5 and: Selenium server <= 3.8.1 started with the option -enablePassThrough false, ...
Read more >
Cannot read property prototype of null web driver exception is ...
I figured out the issue. Chrome browser automatically updated to version 81, though i used chrome driver version 81 it is failing.
Read more >
Releases - CodeceptJS
3.3.5. 🛩️ Features. Added TypeScript types for CodeceptJS config. Update codecept.conf.js to ... Fixes cannot read property indexOf of undefined error.
Read more >
"TypeError: browser.browsingContext is null" for WebDriver ...
It returns Error 500 with "TypeError: browser.browsingContext is null" as a message. Also when closing the tab selected when starting geckodriver it fails ......
Read more >
WebDriver::seeInField() - Code Metrics - Scrutinizer CI
WebDriver ::seeInField() A ... Total Lines, 5 ... or the assigned type should be added to the documentation/type hint for that property.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found