JavascriptError: javascript error: require is not defined

68 views
Skip to first unread message

Moez Ben Rebah

unread,
Feb 20, 2023, 5:05:45 AM2/20/23
to ChromeDriver Users
Hello guys,
I'm trying to test a react redux application project using chrome webdriver where the first task is a simple function that reads data from a json file. I used my selenium script to test if that function returns the correct output

So, whenever I attempt to execute my selenium script: I have the below error:
.../node_modules/selenium-webdriver/lib/error.js:524
    let err = new ctor(data.message)
              ^

JavascriptError: javascript error: require is not defined
  (Session info: chrome=110.0.5481.100)

And If use the "import" statement it returns another error:
.../node_modules/selenium-webdriver/lib/error.js:524
    let err = new ctor(data.message)
              ^

JavascriptError: javascript error: Cannot use import statement outside a module
  (Session info: chrome=110.0.5481.100)

please help me
Reply all
Reply to author
Forward
0 new messages