webview

Appium+python自动化13-native和webview切换

若如初见. 提交于 2020-01-14 20:16:05
前言 现在大部分app都是混合式的native+webview,对应native上的元素通过 uiautomatorviewer 很容易定位到,webview上的元素就无法识别了。 一、识别webview 1.用定位工具查看页面,发现页面上有些区域无法定位到,如下图左边红色区域,只能定位到这个大框框,红色框里面的元素是无法识别的。 2.这时候可以查看元素属性,如右图它的class属性,上面写着WebView,那毫无疑问这种页面就是webview了。 二、contexts 1.context是中文翻译是上下文,环境,当然学过selenium的同学,也可以理解为句柄(handle),其实是一回事,反正知道是两个不同的环境就行了。 2.先获取页面是contexts环境,如下图红色区域,获取的是一个list列表: NATIVE_APP:这个就是native,也就是原生的 WEBVIEW_com.xxxx :这个就是webview 3.当看到打印出来有下图两个,就说明获取到webview的context了(当然也有的app有坑,可能明明有webview,却通过contexts获取不到, 那是开发没打开webview调试) 三、切换到webview 1.要想操作webview上的元素,第一步需要切换环境(跟selenium的切换iframe,切换handle思路是一样) 2.切换方法

Android enable back button in webview

倖福魔咒の 提交于 2020-01-14 19:51:51
问题 I'm using the following code to display a webview in my Android app. package com.company.myapp; import com.google.android.apps.analytics.GoogleAnalyticsTracker; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.Window; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; public class ArticlesActivity extends Activity { /** Initialize the Google Analytics

手机右划触发回退事件保证和头部回退按钮功能一致

放肆的年华 提交于 2020-01-14 16:07:24
APP端因为头部回退按钮是直接关闭当前的webview页面,而手机右划事件只能逐级回退,为保证用户正确体验,在打开新的webview之后,跳转最后一个页面的时候用locationReplace代替locationPush跳转 来源: https://www.cnblogs.com/hydq3334/p/12191931.html

Chromecast sender APIs for WebView based app on Android 4.4

帅比萌擦擦* 提交于 2020-01-14 14:20:28
问题 I read that WebView component in Android 4.4 is based on Chrome: https://developers.google.com/chrome/mobile/docs/webview/overview#does_the_webview_support_the_chrome_apps_apis However, support for Chrome Apps API is still not there. Does this mean that my WebView based app cannot use Chromecast Sender APIs ? 回答1: That is correct, you do not have the needed extension and APIs to use the (pure) chrome WebView to communicate with a chromecast device. As a side note, you cannot do that in the

让Android的WebView支持html里面的文件上传

早过忘川 提交于 2020-01-14 11:39:36
默认情况下,Android的webview是不支持<input type=file>的,点击没有任何反应,如果希望点击上传,弹出选择文件、图片的窗口,那就需要自定义一个WebChromeClient public class MyChromeClient extends WebChromeClient { public ValueCallback<Uri> UploadMsg; public ValueCallback<Uri[]> UploadMsg2; private Activity activity; public static final int FILECHOOSER_RESULTCODE = 5173; public static String mCameraFilePath = ""; @SuppressWarnings("deprecation") public MyChromeClient(Activity cordova) { this.activity = cordova; } @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); } // <input type="file"

White screen after closing fullscreen video opened from WebView

主宰稳场 提交于 2020-01-14 10:28:09
问题 I have a WebView with embedded youtube video. I've implemented fullscreen mode using simple dialog solution like this: webView.setWebChromeClient(new CustomWebChromeClient()); public class CustomWebChromeClient extends WebChromeClient { @Override public void onShowCustomView(View view, CustomViewCallback callback) { Dialog dialog = new Dialog(ArticleDetailsActivity.this, android.R.style.Theme_Black_NoTitleBar_Fullscreen); view.setBackgroundColor(getResources().getColor(R.color.black)); dialog

How to hide scrollbar in WebView?

二次信任 提交于 2020-01-14 06:45:34
问题 I switched to WKWebView because UIWebView is no longer recommended to be used by Apple. Loading the HTML File from the Container in WebView using this code: let webview = myWKWebViewClass.webview(for: Bundle.main.filename) webview.scrollView.isScrollEnabled = false myContainerView.addSubview(webview) works quite fine. But the scrollbar that was hidden while using UIWebView gets displayed when I'm using WKWebView. Using this css-style attributes is also not working (but using UIWebView it

Android webview video to play in mediaplayer

我怕爱的太早我们不能终老 提交于 2020-01-14 05:05:14
问题 I'm currently building an app which shows a content with html tags. The content has a HTML5 video tag which shows video from an external source. By using webview.loadDataWithBaseURL(), I load the html page. The webview shows the video along with the controls (play, stop, etc.). What I want to do is when I clicked the video, it will fire the android default mediaplayer intent downloading and playing the video source, not playing the video inline with the webview By which way to achieve this

Android: WebView onClick not work?

余生颓废 提交于 2020-01-14 04:46:46
问题 I going to hide and show the Layout onclick of the webview. I have code like below: @Override public void onClick(View v) { switch(v.getId()){ case R.id.backButton: finish(); break; case R.id.webView: if(bottomShow){ bottomLayout.setVisibility(View.GONE); bottomShow = false; } else{ bottomLayout.setVisibility(View.VISIBLE); bottomShow = true; } break; } } I have also set the clickListener as like webView.setOnClickListener(this); but even after doing that i am not getting any effect. Why i am

Android: WebView onClick not work?

南楼画角 提交于 2020-01-14 04:46:09
问题 I going to hide and show the Layout onclick of the webview. I have code like below: @Override public void onClick(View v) { switch(v.getId()){ case R.id.backButton: finish(); break; case R.id.webView: if(bottomShow){ bottomLayout.setVisibility(View.GONE); bottomShow = false; } else{ bottomLayout.setVisibility(View.VISIBLE); bottomShow = true; } break; } } I have also set the clickListener as like webView.setOnClickListener(this); but even after doing that i am not getting any effect. Why i am