在IpadAir中使用appium进行测试时,无法启动量角器脚本

时间:2016-04-13 13:38:59

标签: angularjs node.js protractor appium appium-ios

我有一个Angular网站,我想用appium和量角器进行测试。我制作了以下配置文件:

defmodule Plug.Range do                                                                                       
  @behaviour Plug                                                                                             
  @allowed_methods ~w(GET HEAD)                                                                               
  import Plug.Conn                                                                                            

  def init(options) do                                                                                        
    options                                                                                                   
  end                                                                                                         

  def call(conn, _opts) do                                                                                    
    if (Enum.empty?(Plug.Conn.get_req_header(conn, "range"))) do                                              
      conn                                                                                                    
    else                                                                                                      
      file_path = "priv/static" <> conn.request_path                                                          
      if File.exists? file_path do                                                                            

        stats = File.stat! file_path                                                                          
        filesize = stats.size                                                                                 

        req = Regex.run(~r/bytes=([0-9]+)-([0-9]+)?/, conn |> Plug.Conn.get_req_header("range") |> List.first)

        {req_start, _} = req |> Enum.at(1) |> Integer.parse                                                   
        {req_end, _} = req |> Enum.at(2, filesize |> to_string) |> Integer.parse                              

        file_end = ( filesize - 2) |> to_string                                                               

        length = req_end - req_start + 1                                                                      

        conn                                                                                                  
        |> Plug.Conn.put_resp_header("Content-Type", "video/mp4")                                             
        |> Plug.Conn.put_resp_header("Accept-Ranges", "bytes")                                                
        |> Plug.Conn.put_resp_header("Content-Range", "bytes #{req_start}-#{req_end}/#{filesize}")            
        |> Plug.Conn.send_file(206, file_path, req_start, length)                                             
        |> Plug.Conn.halt                                                                                     
      else                                                                                                    
        conn                                                                                                  
      end                                                                                                     
    end                                                                                                       
  end                                                                                                         
end           

test1.js包含我的测试脚本由appium recorder通过choosig Node.js选项生成:

exports.config = {
  allScriptsTimeout: 600000,
  seleniumAddress: 'http://0.0.0.0:4723/wd/hub',

  specs: [
    'testsuite/test1.js'
  ],

  capabilities: {
    browserName: 'safari',
   'appium-version': '1.4.13',
    platformName: 'iOS',
    platformVersion: '9.3',
    deviceName: 'iPad Air'
},

  chromeOnly: false,

  frameworks:[
    'mocha',
    'chai'
  ],

mochaOpts: {

    defaultTimeoutInterval:1000000
}
};  

运行Appium服务器并启动protractor.config.js文件后出现此错误

"use strict";

var wd = require("wd");
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");

chai.use(chaiAsPromised);

var expect = chai.expect;

chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

describe('my app', function() {
it('should make the login test',function()  {
var browser = wd.promiseChainRemote("0.0.0.0", 4723);

browser.init(desired).then(function() {
        return browser
                .elementByXPath("//UIAApplication[1]/UIAWindow[2]/UIAButton[2]").sendKeys("0.22.82:4180/jws/fetablet_dev_T1000")

                .elementByXPath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIAStaticText[1]").sendKeys("RET02")
                .elementByXPath("//UIAApplication[1]/UIAWindow[2]/UIAButton[2]").sendKeys("RET02")
                .elementByXPath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIAStaticText[2]").sendKeys("RET02")
                .fin(function() {
                        return browser.quit();
                });
}).done();
});
});
ᐧ

1 个答案:

答案 0 :(得分:1)

Jasmine无法加载测试,因为规范末尾有额外的字符,请将其删除。