macaca icon indicating copy to clipboard operation
macaca copied to clipboard

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

Open gao2q opened this issue 7 years ago • 1 comments

  • Macaca Version: 2.0.13

  • Macaca Doctor Logs:
    macaca-doctor version: 2.0.4

    Node.js checklist:

    node env: /usr/local/bin/node node version: v8.9.3

    iOS checklist:

    Xcode Command Line Tools is ready, version: 2349. xcodebuild version: 9.2 iproxy[usbmuxd] is installed at: /usr/local/bin/iproxy ios_webkit_debug_proxy is installed at: /usr/local/bin/ios_webkit_debug_proxy carthage is installed, version: 0.28.0

    Android checklist:

    JAVA version is 1.8.0_101 JAVA_HOME is set to /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home ANDROID_HOME is not set Command Line Tools: gradle is uninstalled

    Installed driver list:

    ios: 2.0.30

  • Operate System: macOS 10.13.3 iphone 6 ios 11.2.5

  • Programming Language: node.js

  • 脚本:

var wd = require('macaca-wd');

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 () 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 () 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 () 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 () 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 () 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 () 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 avatar Feb 06 '18 10:02 gao2q

调试了源代码,真机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浏览器?

gao2q avatar Feb 09 '18 01:02 gao2q