// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage

//testcase name：新增参数
//author：feizhao
//date：2017-11-21
//discription：用于测试登陆后，综合业务-参数管理的页面新增参数
//step：1.登录主页面  2.新增参数  3.录入新增参数信息  4.环境恢复
//修改人：
//修改日期：
//修改内容：

//Account setting.
 const accountConfig = {
  username: '1',
  password: '1',
}
 module.exports = {
   'login tests': function (browser) {
     browser
     .url('http://127.0.0.1:8080').maximizeWindow()
     .pause(1000)
     .waitForElementVisible('body', 100)
     .setValue('input[type=text]',accountConfig.username)
     .pause(100)
     .setValue('input[type=password]',accountConfig.password)
     .pause(100)
     .click('button[id=login-button]')
     .pause(1000)
//点击综合业务-参数管理-新增参数
     .click('#vc-tree-name-综合业务')
     .pause(1000)
     .click('#vc-tree-name-参数管理')
     .pause(3000)
     .click('#unit :first-child div :first-child span')
     .pause(1000)
     .setValue('#unit :first-child div :nth-child(4) div div :nth-child(2) div input[type=text]','测试新增参数')
     .pause(1000)
     .click('#unit :first-child div :nth-child(4) div div :nth-child(3) :last-child')
     .pause(1000)
     browser.expect.element('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)').text.to.equal('测试新增参数')
     browser.pause(1000)
     //新增参数下拉选项录入
     .click('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)')
     .pause(1000)
     .click('#unit div div :nth-child(4) span')
     .pause(1000)
     .setValue('#unit div div :nth-child(6) div div :nth-child(2) input[type=text]','新增测试')
     .pause(1000)
     .click('#unit div div :nth-child(6) div div :nth-child(3) :last-child ')
     .pause(1000)
     browser.expect.element('#unit div div :nth-child(5) div div table :nth-child(2) tr td:nth-child(2)').text.to.equal('新增测试')
//环境恢复
     browser.pause(1000)
     .click('#unit div div :nth-child(5) div div table :nth-child(2) tr td:nth-child(3) button:last-child')
     .pause(1000)
     .click('#vc-messagebox-confirm')
     .pause(1000)
     .click('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(3) button:last-child')
     .pause(1000)
     .click('#vc-messagebox-confirm')
     .pause(1000)
     browser.expect.element('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)').text.not.to.equal('测试新增参数')
     browser.pause(3000)
     .end()
   }
 }
