मैं नोड और नाइटवॉच के लिए नया हूं और मेरे पास हैस्थापित नोड, एनपीएम, सेलेनियम अकेले खड़े होने से सभी शुरू होने वाले निर्देशों का पालन करते हुए, सेलेनियम ड्राइवर शुरू करते हुए, मैंने क्रोम ड्राइवर को भी डाउनलोड किया और इसे उसी निर्देशिका में रखा। मैंने conf फाइल और एक साधारण टेस्ट केस js बनाया है। जब मैं नोड कमांड लाइन के माध्यम से परीक्षण मामले को चलाने के लिए जाता हूं, तो मुझे एक त्रुटि मिलती रहती है:
Error: Cannot find module "C:Usersx203946tests"
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3
Nightwatch.js
{
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "pages",
"globals_path": "globals",
"selenium": {
"start_process": true,
"server_path": "node_modules/selenium-standalone/.selenium/selenium-
server/",
"log_path": "./reports",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": ""
}
},
"test_settings": {
"default": {
"launch_url": "https://localhost",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
Nightwatch.conf.js
require("babel-core/register");
const fs = require("fs");
module.exports = ((settings) => {
const seleniumFileName =
fs.readdirSync("node_modules/selenium-standalone/.selenium/selenium-
server/");
settings.selenium.server_path += seleniumFileName;
return settings;
})(require("./nightwatch.json"));
परीक्षा
module.exports = {
"Does not show the task list if there are no tasks"(client) {
client
.url("http://todomvc.com/examples/react/#/")
.waitForElementVisible(".header h1")
.expect.element(".main").to.not.be.present;
client.end();
},
उत्तर:
जवाब के लिए 0 № 1आपने नाइटवॉच में "परीक्षण" निर्दिष्ट किया।जेएस लेकिन परीक्षण फ़ाइल "परीक्षण" निर्देशिका में है इसलिए निर्देशिका का एक नाम "परीक्षण" से "परीक्षण" तक कम से कम तय होगा। इसके अलावा, मुझे लगता है कि आपको कॉन्फिग फाइल नाइटवॉच.जसन नाम देना चाहिए