2017-07-19 34 views
0

这是我使用运行我的测试代码为什么我的测试不加载我的页面目标文件? (Nightwatch.js)

this is my config file. 
{ 
    "src_folders" : ["tests"], 
    "output_folder" : "reports", 
    "custom_commands_path" : "", 
    "custom_assertions_path" : "", 
    "page_objects_path" : "./pages/affirm.js", 
    "globals_path" : "./data/data_for_requestinfo.js", 

    "selenium" : { 
    "start_process" : true, 
    "server_path" : "/Users/davidcastro/Automation/bin/selenium-server- 
standalone-3.4.0.jar", 
    "log_path" : "", 
    "port" : 4444, 
    "cli_args" : { 
     "webdriver.chrome.driver" : 
    "/Users/davidcastro/Automation/Drivers/chromedriver", 
     "webdriver.gecko.driver" : 
"/Users/davidcastro/Automation/Drivers/geckodriver", 
    "webdriver.edge.driver" : "" 
    } 
    }, 

    "test_settings" : { 
    "default" : { 
     "launch_url" : "https://www.affirmpronebiopsy.com/", 
     "selenium_port" : 4444, 
     "selenium_host" : "localhost", 
     "silent": true, 
     "screenshots" : { 
     "enabled" : false, 
     "path" : "" 
     }, 
     "desiredCapabilities": { 
     "browserName": "firefox", 
     "marionette": true 
     } 

    }, 
    "brevera" : { 
     "launch_url" : "https://prod.breverabiopsy.com/", 
     "desiredCapabilities": { 
     "browserName": "chrome", 
     "javascriptEnabled": true, 
     "acceptSslCerts": true 
     } 
    }, 

    "chrome" : { 
    "desiredCapabilities": { 
     "browserName": "chrome" 
     } 
    }, 

    "edge" : { 
     "desiredCapabilities": { 
     "browserName": "MicrosoftEdge" 
     } 
     } 
    } 
} 



This is my page file 

module.exports = { 
    elements: { 
    name: { 
     selector: "input[type=text]" 
    }, 
    email: { 
     selector: 'input[type=email]' 
    }, 
    country:{ 
     selector: 'select[id=edit-country]' 
    }, 
    submit: { 
     selector: 'input[id=edit-submit]' 
    } 
    } 
}; 

这是我的测试文件

module.exports = { 
'Request info ' : function (client) { 
var data = client.globals; 
    var myPageObject = client.page.affirm(); 

client 
    .url(client.launch_url + '/request-info') 
    .waitForElementPresent('body', 1000) 
    .setValue("@name", [data.name, client.Keys.ENTER]) 
    .pause(1000) 
    .setValue('@email', [data.email]) 
    .pause(1000) 
    .setValue('@country', [data.country]) 
    .pause(1000) 
    .click('@submit') 
    .pause(1000) 
    .assert.containsText('main', 'Thank you for your interest!') 
    .saveScreenshot('./screenshots/search-result.png') 
    .pause(1000) 
    .end(); 

} };

我试着在我的配置文件中多次改变了路径:./pages, 并改变了我在测试中调用它的方式:var page = client.page()并运行我的测试,但没有我在我的页面文件中命名的字段,所以我得到错误。

上面我所提到的配置得到这个错误:The error

是有什么我做错了什么?

回答

0

如果您的nightwatch.conf.js文件位于与datapages相同的目录中,请尝试写入没有初始'。'的路径。前面。例如:

"page_objects_path" : "/pages/affirm.js" 
+0

我已经尝试了这一点,我仍然得到上面提到的错误。 – DavidCastro

1

页对象路径应该是一个目录,而不是文件

"page_objects_path" : "./pages" 
相关问题