Appium 运行 WebDriverAgent 输入./Scripts/bootstrap.sh 报错

yefengjun · 2017年01月20日 · 最后由 yefengjun 回复于 2017年01月22日 · 2822 次阅读

在真机上WebDriverAgentRunner可以打开,但是在终端输入./Scripts/bootstrap.sh后报错,报错信息如下 请各位帮忙看一下怎么解决。我从git上重新下了个WebDriverAgent但是还是同样的错误

bogon:WebDriverAgent yefengjun$ ./Scripts/bootstrap.sh
Fetching dependencies
Building Inspector
Creating bundle directory...
Fetching Inspector dependencies...
npm WARN react-treeview@0.4.6 requires a peer of react@>=0.14.0 but none was installed.
npm WARN web-driver-inspector@1.0.0 No repository field.
Building Inspector...

> web-driver-inspector@1.0.0 build /Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector
> webpack --progress --colors

Hash: 9ed7d0b85cc08341fd0f
Version: webpack 1.14.0
Time: 72ms
[0] multi main 28 bytes {0} [built] [1 error]
+ 1 hidden modules

ERROR in ./js/app.js
Module parse failed: /Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/js/app.js Unexpected token (59:4)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (59:4)
at Parser.pp$4.raise (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp$3.parseExprAtom (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1822:12)
at Parser.pp$3.parseExprSubscripts (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1715:21)
at Parser.pp$3.parseMaybeUnary (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1692:19)
at Parser.pp$3.parseExprOps (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1620:21)
at Parser.pp$3.parseMaybeAssign (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1597:21)
at Parser.pp$3.parseParenAndDistinguishExpression (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1861:32)
at Parser.pp$3.parseExprAtom (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1796:19)
at Parser.pp$3.parseExprSubscripts (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1715:21)
at Parser.pp$3.parseMaybeUnary (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1692:19)
at Parser.pp$3.parseExprOps (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1620:21)
at Parser.pp$3.parseMaybeAssign (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1597:21)
at Parser.pp$3.parseExpression (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1573:21)
at Parser.pp$1.parseReturnStatement (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:839:33)
at Parser.pp$1.parseStatement (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:699:34)
at Parser.pp$1.parseBlock (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$3.parseFunctionBody (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:2105:24)
at Parser.pp$3.parseMethod (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:2075:10)
at Parser.pp$1.parseClassMethod (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1137:25)
at Parser.pp$1.parseClass (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:1118:14)
at Parser.pp$1.parseStatement (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:697:19)
at Parser.pp$1.parseTopLevel (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock.<anonymous> (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
@ multi main
Done
共收到 9 条回复 时间 点赞

@chenhengjie123 这个问题重新开了一个帖子,麻烦再帮忙看一下吧,感谢!我重新换了一个WebDriverAgent 还是同样的问题。不知道怎么搞了....

奇怪了,我把WebDriverAgent文件夹放到别的目录下之后运行./Scripts/bootstrap.sh就成功了,回到原来Appium的目录下就不行
这是终端的信息

bogon:WebDriverAgent yefengjun$ ./Scripts/bootstrap.sh
Fetching dependencies
Building Inspector
Creating bundle directory...
Fetching Inspector dependencies...
npm WARN react-treeview@0.4.6 requires a peer of react@>=0.14.0 but none was installed.
npm WARN web-driver-inspector@1.0.0 No repository field.
Building Inspector...

> web-driver-inspector@1.0.0 build /Users/yefengjun/Documents/WebDriverAgent/Inspector
> webpack --progress --colors

Hash: 464241247f16d853b410
Version: webpack 1.14.0
Time: 1816ms
Asset Size Chunks Chunk Names
inspector.js 712 kB 0 [emitted] main
[0] multi main 28 bytes {0} [built]
+ 182 hidden modules
Done

你试试看 ./Scripts/bootstrap.sh -d

#3楼 @lunamagic -d 显示的是这样的,没有看到building啊?

bogon:WebDriverAgent yefengjun$ ./Scripts/bootstrap.sh -d
Fetching dependencies
bogon:WebDriverAgent yefengjun$

官方 issue :https://github.com/appium/appium/issues/7088

官方已经回复了,不支持运行 WebDriverAgent 自带的 inspector 。

至于为何单独移出来就可以用,我猜和 webpack 检测相对目录的根目录有关。有兴趣你可以细究下。

找到原因了,webpack 的配置文件里面 exclude 了 node_modules 文件夹,你改变路径前 WebDriverAgent 刚好在 appium 的 node_modules 文件夹中,里面的文件都被忽略了,所以报错。

修改方法:

/Users/hengjiechen/.nvm/versions/node/v4.2.6/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector/webpack.config.js 中的

...
loaders: [
{ test: /\.js?$/, loaders: ['babel-loader'], exclude: /node_modules/ },
{ test: /\.css?$/, loader: 'style-loader!css-loader' },
]
...

改为

...
loaders: [
{ test: /\.js?$/, loaders: ['babel-loader'] },
{ test: /\.css?$/, loader: 'style-loader!css-loader' },
]
...

, exclude: /node_modules/ 这部分去掉即可。不过我只确定能打包成功,能不能正常运行没试过,你可以试下。

#6楼 @chenhengjie123 非常感谢!我试了一下

yefengjundeMacBook-Pro:WebDriverAgent yefengjun$ ./Scripts/bootstrap.sh
Fetching dependencies
Building Inspector
Creating bundle directory...
Fetching Inspector dependencies...
npm WARN react-treeview@0.4.6 requires a peer of react@>=0.14.0 but none was installed.
npm WARN web-driver-inspector@1.0.0 No repository field.
Building Inspector...

> web-driver-inspector@1.0.0 build /Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector
> webpack --progress --colors

Hash: 30b1e7620a314d43cf44
Version: webpack 1.14.0
Time: 4269ms
Asset Size Chunks Chunk Names
inspector.js 700 kB 0 [emitted] main
[0] multi main 28 bytes {0} [built]
+ 182 hidden modules
Done

这样就是可以了吧?这两个警告有影响吗?

#7楼 @yefnegjun 应该不影响。

#8楼 @chenhengjie123 好的,感谢!

yefengjun 关闭了讨论 01月22日 09:28
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册