ScriptException ReferenceError:测试浏览器表单时未定义“导出”

时间:2019-08-02 18:20:03

标签: javascript scala selenium-webdriver play-framework-2.7

尝试为我的播放框架应用程序运行浏览器测试时。我收到与其中一个JavaScript文件有关的ReferenceError: "exports" is not defined.

因此,当启动应用程序但尝试使用GuiceOneServerPerSuiteOneBrowserPerSuiteHtmlUnitFactory进行集成测试时,此验证脚本将起作用。我收到一条错误消息,指出

org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "exports" is not defined. (http://localhost:62937/assets/assets/js/inputvalidation.js#53)

我尝试删除出口,但错误仍然存​​在。 任何帮助,将不胜感激。

validation.js

var decimalOnly = /^\s*-?[0-9]\d*(\.\d{1,2})?\s*$/;

testInputData = function (data, restrictionType) {
    return restrictionType.test(data) && isFinite(data) && parseFloat(data) > 0;
};

exports.testInputData = function (data, restrictionType) {
    return testInputData(data, restrictionType); };

exports.decimalOnly = function(){
    return decimalOnly; };

class BrowserSpec extends PlaySpec with GuiceOneServerPerSuite with OneBrowserPerSuite with HtmlUnitFactory {

  "The browser should" must {
    "successfully process a form" in {
      val processCalculatorURL = 
      controllers.routes.ApplicationController
      .index().absoluteURL(false, s"localhost:$port")

      go to processCalculatorURL
     }
   }
}

应该能够完成测试而不会摔倒。

0 个答案:

没有答案