 helpers = require './helpers.js'
 assert  = require 'assert'
 
+modalSelector = '.machine-settings-modal.AppModal'
 
 module.exports =
 

      .waitForElementVisible  '.settings form.with-fields .moreview', 20000
      .click                  '.settings form.with-fields .moreview'
      .pause                  2000


  clickAddVMButton: (browser) ->

    user = helpers.beginTest(browser)
    helpers.waitForVMRunning(browser)

    buttonSelector     = '.domains .kdheaderview button.add-button'
    buttonLoaderSelector = '.add-view button.loading'
    paragraph          = helpers.getFakeText()
    createDomainName   = paragraph.split(' ')[0]
    domainName         = createDomainName + '.' + user.username + '.dev.koding.io'

    @openDomainSettings(browser)

    browser
      .waitForElementVisible    buttonSelector, 20000
      .click                    buttonSelector
      .waitForElementVisible    '.add-view input.hitenterview', 20000
      .setValue                 '.add-view input.hitenterview', createDomainName + '\n'
      .waitForElementVisible    buttonLoaderSelector, 10000
      .waitForElementNotVisible buttonLoaderSelector, 20000
      .assert.containsText      '.kdlistitemview-domain:last-child' , domainName

    return domainName

