// 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 :nth-child(2) div :first-child span')
     .pause(1000)
     .setValue('#unit :nth-child(2) div :nth-child(4) div div :nth-child(2) div:first-child input[type=text]','测试新增单值-名称')
     .pause(1000)
     .setValue('#unit :nth-child(2) div :nth-child(4) div div :nth-child(2) div:last-child input[type=text]','测试新增单值-内容')
     .pause(1000)
     .click('#unit :nth-child(2) div :nth-child(4) div div :nth-child(3) :last-child')
     .pause(1000)
     .click('#unit :nth-child(2) div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(4) button:first-child')
     .pause(1000)
     //修改单值
     .clearValue('#unit :nth-child(2) div :nth-child(4) div div :nth-child(2) div:first-child input[type=text]')
     .pause(500)
     .clearValue('#unit :nth-child(2) div :nth-child(4) div div :nth-child(2) div:last-child input[type=text]')
     .pause(500)
     .setValue('#unit :nth-child(2) div :nth-child(4) div div :nth-child(2) div:first-child input[type=text]','测试修改单值-名称')
     .pause(1000)
     .setValue('#unit :nth-child(2) div :nth-child(4) div div :nth-child(2) div:last-child input[type=text]','测试修改单值-内容')
     .pause(1000)
     .click('#unit :nth-child(2) div :nth-child(4) div div :nth-child(3) :last-child')
     .pause(1000)
     browser.expect.element('#unit :nth-child(2) div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)').text.to.equal('测试修改单值-名称')
     browser.pause(1000)
     browser.expect.element('#unit :nth-child(2) div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(3)').text.to.equal('测试修改单值-内容')
     browser.pause(1000)
//环境恢复
     .click('#unit :nth-child(2) div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(4) button:last-child')
     .pause(1000)
     .click('#vc-messagebox-confirm')
     .pause(1000)
     browser.expect.element('#unit :nth-child(2) div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)').text.not.to.equal('测试修改单值-名称')
     browser.pause(3000)
     .end()
   }
 }
