alibaba / macaca

Automation solution for multi-platform. 多端自动化解决方案
https://macacajs.github.io
MIT License
3.17k stars 418 forks source link

iOS真机测试Safari报错 TypeError: this.device.openURL is not a function #787

Open gao2q opened 6 years ago

gao2q commented 6 years ago

var remoteConfig = { host: 'localhost', port: 4444 };

var driver = wd.promiseChainRemote(remoteConfig);

describe('Test', function () {

before(function () { return driver.init({ platformName: 'iOS', // iOS, Android, Desktop udid: '****', bundleId: 'com.apple.mobilesafari', }); });

after(function () { return driver .sleep(1000) .quit(); });

it('url: https://www.baidu.com', async function () { await driver.get('https://www.baidu.com'); });

});



* **问题**:
以上脚本在iOS模拟器运行正常。
但是,使用iOS真机Safari浏览器出现错误。

看到issues中有同样的问题,但是对应修改我没有解决。  
 ios真机,server报错 #517   
请问如何解决。  

* **macaca server日志**:

>> responseHandler.js:62:14 [master] pid:10916 TypeError: this.device.openURL is not a function
    at IOS.get (/usr/local/lib/node_modules/macaca-ios/lib/macaca-ios.js:492:23)
    at IOS.get.next (<anonymous>)
    at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:65:19)
    at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
    at new Promise (<anonymous>)
    at Object.co (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:50:10)
    at Object.toPromise (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:118:63)
    at next (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:99:29)
    at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:69:7)
    at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
    at new Promise (<anonymous>)
    at Object.co (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:50:10)
    at Object.toPromise (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:118:63)
    at next (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:99:29)
    at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:69:7)
    at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
  TypeError: this.device.openURL is not a function
      at IOS.get (/usr/local/lib/node_modules/macaca-ios/lib/macaca-ios.js:492:23)
      at IOS.get.next (<anonymous>)
      at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:65:19)
      at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
      at new Promise (<anonymous>)
      at Object.co (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:50:10)
      at Object.toPromise (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:118:63)
      at next (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:99:29)
      at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:69:7)
      at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
      at new Promise (<anonymous>)
      at Object.co (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:50:10)
      at Object.toPromise (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:118:63)
      at next (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:99:29)
      at onFulfilled (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:69:7)
      at /usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:54:5
gao2q commented 6 years ago

调试了源代码,真机ios下没有openURL方法。

IOS.prototype.get = function * (url) {
  if (this.isSafari || this.proxy) {

    yield this.device.openURL(url);

    yield _.sleep(2000);
    if (!this.remote) {
      this.remote = new RemoteDebugger({
        deviceId: this.udid
      });
      yield this.remote.start();
    }
    const availablePages = yield this.remote.getPages();
    const latestPage = _.last(availablePages);
    if (latestPage) {
      const pageId = latestPage.id;
      yield this.remote.connect(pageId);
      this.context = pageId;
    }
    this.frame = null;
    return null;
  } else {
    this.frame = null;
    return yield this.remote.navigateTo(url);
  }
};

请问macaca是否支持ios真机的safari浏览器?