Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript nightwatch.js internet explorer_Javascript_Selenium_E2e Testing_Nightwatch.js - Fatal编程技术网

Javascript nightwatch.js internet explorer

Javascript nightwatch.js internet explorer,javascript,selenium,e2e-testing,nightwatch.js,Javascript,Selenium,E2e Testing,Nightwatch.js,我正在使用nightwatch测试我的javascript应用程序。我需要能够在本地计算机上运行跨浏览器测试。Chrome和Firefox还可以,但在IE上运行测试时,我遇到了一个错误: Running: google.com TypeError: undefined is not a function at pass (C:\Users\Dávid\AppData\Roaming\npm\node_modules\nightwatch\lib\api\ assertions\

我正在使用nightwatch测试我的javascript应用程序。我需要能够在本地计算机上运行跨浏览器测试。Chrome和Firefox还可以,但在IE上运行测试时,我遇到了一个错误:

Running:  google.com
    TypeError: undefined is not a function
    at pass (C:\Users\Dávid\AppData\Roaming\npm\node_modules\nightwatch\lib\api\
assertions\urlContains.js:23:18)
    at Object.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\night
watch\lib\core\assertion.js:94:23)
    at HttpRequest.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\
nightwatch\lib\index.js:299:20)
    at HttpRequest.emit (events.js:110:17)
    at HttpRequest.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\
nightwatch\lib\index.js:346:15)
    at HttpRequest.emit (events.js:118:17)
    at IncomingMessage.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modu
les\nightwatch\lib\http\request.js:150:16)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)
nightwatch.json:

module.exports = {
    'google.com': function(browser){
        return browser
            .url('www.google.com')
            .pause(5000)
            .assert.urlContains('google')
            .end();
    }
}
{
    "src_folders" : ["./tests/e2e"],
    "output_folder" : "./tests/reports",
    "custom_assertions_path" : "",
    "globals_path" : "",
    "live_output" : false,
    "parallel_process_delay" : 10,
    "disable_colors": false,

    "selenium" : {
        "start_process" : true,
        "server_path" : "./bin/selenium-server-standalone-2.45.0.jar",
        "log_path" : "",
        "host" : "127.0.0.1",
        "port" : 4444,
        "cli_args" : {
        "webdriver.chrome.driver" : "",
        "webdriver.ie.driver" : "./bin/IEDriverServer.exe",
        "webdriver.firefox.profile" : ""
    }
},

"test_settings" : {
    "default" : {
        "launch_url" : "http://localhost:3001",
        "selenium_host" : "127.0.0.1",
        "selenium_port" : 4444,
        "silent" : true,
        "disable_colors": false,
        "screenshots" : {
            "enabled" : false,
            "path" : ""
        },
        "desiredCapabilities" : {
            "browserName" : "firefox",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    },
    "chrome": {
        "desiredCapabilities" : {
            "browserName" : "chrome",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    },
    "ie": {
        "desiredCapabilities": {
            "browserName" : "internet explorer",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    }
}
nightwatch --env ie
.assert.urlContains('google')
运行命令:

module.exports = {
    'google.com': function(browser){
        return browser
            .url('www.google.com')
            .pause(5000)
            .assert.urlContains('google')
            .end();
    }
}
{
    "src_folders" : ["./tests/e2e"],
    "output_folder" : "./tests/reports",
    "custom_assertions_path" : "",
    "globals_path" : "",
    "live_output" : false,
    "parallel_process_delay" : 10,
    "disable_colors": false,

    "selenium" : {
        "start_process" : true,
        "server_path" : "./bin/selenium-server-standalone-2.45.0.jar",
        "log_path" : "",
        "host" : "127.0.0.1",
        "port" : 4444,
        "cli_args" : {
        "webdriver.chrome.driver" : "",
        "webdriver.ie.driver" : "./bin/IEDriverServer.exe",
        "webdriver.firefox.profile" : ""
    }
},

"test_settings" : {
    "default" : {
        "launch_url" : "http://localhost:3001",
        "selenium_host" : "127.0.0.1",
        "selenium_port" : 4444,
        "silent" : true,
        "disable_colors": false,
        "screenshots" : {
            "enabled" : false,
            "path" : ""
        },
        "desiredCapabilities" : {
            "browserName" : "firefox",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    },
    "chrome": {
        "desiredCapabilities" : {
            "browserName" : "chrome",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    },
    "ie": {
        "desiredCapabilities": {
            "browserName" : "internet explorer",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    }
}
nightwatch --env ie
.assert.urlContains('google')
这一行失败:

module.exports = {
    'google.com': function(browser){
        return browser
            .url('www.google.com')
            .pause(5000)
            .assert.urlContains('google')
            .end();
    }
}
{
    "src_folders" : ["./tests/e2e"],
    "output_folder" : "./tests/reports",
    "custom_assertions_path" : "",
    "globals_path" : "",
    "live_output" : false,
    "parallel_process_delay" : 10,
    "disable_colors": false,

    "selenium" : {
        "start_process" : true,
        "server_path" : "./bin/selenium-server-standalone-2.45.0.jar",
        "log_path" : "",
        "host" : "127.0.0.1",
        "port" : 4444,
        "cli_args" : {
        "webdriver.chrome.driver" : "",
        "webdriver.ie.driver" : "./bin/IEDriverServer.exe",
        "webdriver.firefox.profile" : ""
    }
},

"test_settings" : {
    "default" : {
        "launch_url" : "http://localhost:3001",
        "selenium_host" : "127.0.0.1",
        "selenium_port" : 4444,
        "silent" : true,
        "disable_colors": false,
        "screenshots" : {
            "enabled" : false,
            "path" : ""
        },
        "desiredCapabilities" : {
            "browserName" : "firefox",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    },
    "chrome": {
        "desiredCapabilities" : {
            "browserName" : "chrome",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    },
    "ie": {
        "desiredCapabilities": {
            "browserName" : "internet explorer",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    }
}
nightwatch --env ie
.assert.urlContains('google')

感谢您的帮助。

我尝试了您的测试,它在我的笔记本电脑Nightwatch v0.6.13上运行良好。你使用哪个版本的Nighwatch?(npm list nightwatch-g)

我通过禁用所有区域的IE保护模式,并将所有区域的安全性降低到最低级别,解决了这个问题。

我知道你已经找到了解决方案,但我自己也经历了这一点,我想我会把这个留给未来的人

假设Internet Explorer需要特定的配置

  • IEDriverServer需要位于路径中。我的经验是,使用%PATH%令人惊讶地不可靠,我:

    • webdriver.ie.driver
      设置为nightwatch.json的
      cli_args
      中的路径
    • 使用
      java-jar Selenium-Server-standalone-2.47.1.jar-Dwebdriver.ie.driver=。\IEDriverServer.exe
  • IE中的受保护模式(工具>Internet选项>安全性)对于所有区域都需要相同(正如您所发现的!)。我经常在本地和虚拟机上进行测试,所以我为本地和受信任启用了它,而不是为Internet区域禁用它

  • 将缩放设置为100%(尽管,你知道,为什么不呢?)

  • 对于IE10+,需要禁用增强的保护模式(工具>Internet选项>高级>安全)。可以肯定的是,这在Windows的客户端版本上默认是禁用的,但在服务器版本上是启用的

  • 对于IE11+,执行reghack以促进selenium服务器和浏览器实例之间的连接。在
    HKEY\u LOCAL\u MACHINE\SOFTWARE\Microsoft\internetexplorer\Main\FeatureControl\FEATURE\u BFCACHE
    中,为
    iexplore.exe
    添加一个DWORD,并将其设置为
    0
    。如果您运行的是64位windows,则该路径将变为
    HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE\u BFCACHE

根据我的经验,还有一点:

  • 如果您使用的是64位windows,请不要被64位IEDriverServer所诱惑。很慢。“比自动取款机前面的老太太慢”慢

nightwatch v0.6.13。您是否复制粘贴了所有内容,包括nighwatch.json?您使用了哪个版本的selenium?嘿,我正在尝试在IE驱动程序中运行selenium测试,我遇到了一些问题,尤其是在nativeEvents设置为true时单击元素。在IE中测试时,您的配置是什么样子的?