ADB可以查看浏览器是否完全加载吗?
我创建了一个应用程序,它通过 ADB 与 Android 模拟器交互,将浏览器发送到特定 URL,然后截取浏览器窗口的屏幕截图。然后我抓取图像并在服务器端将其转换为 JPG。
一切都很好,但是现在我只是执行 thread.sleep() 15 秒,以确保浏览器完成加载我传入的 URL。嗯,这在大多数情况下都可以正常工作,但有些网站已完成加载远远早于15秒,而其他人还需要几秒钟。
我想知道是否有一种方法可以通过 ADB 检查浏览器是否已完成加载,而不是设置静态等待时间?
I've created an app that interacts with the Android Emulator through ADB to send the browser to a particular URL, then screenshot the browser window. I then grab the image and convert it server-side to a JPG.
Everything works great, however right now I am simply doing a thread.sleep() for 15 seconds to make sure the browser is finished loading the URL I pass in. Well, this works fine for the most part, but some sites are done loading way before the 15 seconds, while others still need a few seconds.
I was wondering if there is a way through ADB that I can check if the browser is finished loading instead of setting a static time to wait?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一种方法:打开浏览器后,加载一个 javascript url,一旦页面加载,该 url 将输出到控制台。然后在logcat中查找输出。
在 android 中,所有
console.log()
javascript 调用都会转发到 logcat。 (标签名称取决于操作系统版本,查找控制台、浏览器或 WebCore)示例:
当网站完全加载时,您可以在 logcat 上看到以下行:
There is a way: just after opening the browser, load a javascript url that will output to console once the page is loaded. Then look for the output in logcat.
In android, all
console.log()
javascript calls are forwarded to logcat. (tag name depends on OS version, look for console, browser or WebCore)exemple:
You can then see the following line on logcat, when the website will be fully loaded: