我有一些测试女巫是正确的,但大部分时间都失败了,我不知道为什么会发生这种情况。例如,其中一个测试看起来像这样。
'Create organization' : function (browser) {
browser
.waitForElementPresent('li[ng-class="createOrganizationClass"]', 15000)
.click('li[ng-class="createOrganizationClass"]')
}
这只是测试的开始,但其余的并不重要。问题是元素li[ng-class="createOrganizationClass"]
总是存在,但在某些情况下我得到element is not present
错误,我的测试失败了。为什么会这样,我怎么能避免这种情况?此外,它正在发生另一个因素,所以我的测试大多数时间都是因为这个原因而失败了。
这是我的nightwatch.json
文件。
{
"src_folders" : ["src/tests"],
"output_folder" : "reports",
"custom_commands_path" : "src/customCommands",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.gecko.driver" : "./geckodriver",
"webdriver.edge.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "firefox",
"unexpectedAlertBehaviour": "accept",
"marionette" : true,
"acceptInsecureCerts" : true,
"abortOnAssertionFailure": false
}
}
}
}