使用Task Scheduler时,带有IE的Nightwatch无法正常工作

时间:2019-04-26 12:39:03

标签: selenium nightwatch.js iedriverserver

我想使用Task Scheduler在IE上运行守夜人。我创建了一个仅包含以下行的批处理文件:

nightwatch Test.js --reporter html-reporter.js -e ie

这是我的测试案例(Test.js)的示例:

module.exports = {
  'Initialization' : function (client) {
    client
      .maximizeWindow()
      .url(url)
      .waitForElementVisible('body', 5000)
      .waitForElementVisible('#MainContent_login_username')
      .click('#MainContent_login_username') 
      .clearValue('#MainContent_login_username')
      .setValue('#MainContent_login_username', username)
      .click('#MainContent_login_password')
      .clearValue('#MainContent_login_password')
      .setValue('#MainContent_login_password', password)
      .click('#MainContent_loginBT')

  },
  'Test 1: Start Page Test' : function (client) {
     client
      .waitForElementVisible('body', 10000)
      .waitForElementVisible('#list', 10000)

      .setValue('#search_bar', test_value)
      .pause(500)
      .click('#search_BT')
      .pause(1000)
      .expect.element('#list > tbody > tr:first-child > td:nth-child(1)').text.to.match(regex);
  }
}

当我从命令提示符运行它或手动启动批处理脚本时。此测试有效。但是,当我使用任务计划程序运行它时,它在以下位置失败:

.waitForElementVisible('#list', 10000) //#list is part of the body

在尝试使用Microsoft Edge运行时,我也遇到了同样的问题,但是在与Chrome和Firefox一起运行时,它运行正常。

我该如何解决?

我的nightwatch.json:

{
  "src_folders" : "",
  "output_folder" : "reports",
  "custom_commands_path" : "",
  "page_objects_path" : "",
  "custom_assertions_path" : "",
  "globals_path" : "global/globals.js",
  "live_output" : true,
  "parallel_process_delay" : 10,
  "disable_colors": false,
  "test_workers" : {
    "enabled": true,
    "workers": "auto"
  },

  "selenium" : {
    "start_process" : true,
    "server_path" : "selenium-server-standalone-3.141.59.jar",
    "log_path" : "./reports",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "chromedriver.exe",
      "webdriver.ie.driver" : "IEDriverServer32.exe",
      "webdriver.gecko.driver" : "geckodriver.exe",
      "webdriver.edge.driver" : "MicrosoftWebDriver.exe"
    }
  },

  "test_settings" : {
    "default" : {
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities" : {
        "browserName" : "firefox",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true
      }
    },

    "ff" : {
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities" : {
        "browserName" : "firefox",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true
      }
    },

    "ch" : {
      "desiredCapabilities" : {
        "browserName" : "chrome",
        "chromeOptions": {
          "args" : ["--no-sandbox"]
        },
        "loggingPrefs": {"driver": "INFO", "server": "OFF", "browser": "INFO"}
      }
    },

    "ie" : {
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities" : {
        "browserName" : "internet explorer",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true
      }
    },

    "edge" : {
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities" : {
        "browserName" : "MicrosoftEdge",
        "acceptSslCerts" : true
      }
    }
  }
}

0 个答案:

没有答案