appium定位H5页面

手机端由原生切换为H5,定位不到元素。需要将apk开启调试模式:在入口Activity中添加2行代码,如下
if (Build.VERSION.SDK_INT >=Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}

效果如下:
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
super.onCreate(savedInstanceState);
context = this;
if (Build.VERSION.SDK_INT >=Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
   ......
......
posted @ 2018-09-18 13:06  水工  阅读(174)  评论(0)    收藏  举报