npm 包 appium-remote-debugger 使用教程

阅读时长 4 分钟读完

前言

appium-remote-debugger 是一款基于 appium 的调试工具,能够让我们在 PC 端通过 Chrome 的 devtools 远程调试 Android 或 iOS 设备上的应用。使用 appium-remote-debugger 可以大大提高调试效率,对于前端开发人员来说是一款非常实用的工具。

安装 appium-remote-debugger

appium-remote-debugger 是一款 npm 包,使用 npm 安装即可,你可以通过以下命令安装:

安装完成后,通过以下命令启动 appium-remote-debugger:

使用 appium-remote-debugger

appium-remote-debugger 的使用非常简单,只需要两步即可。

第一步:启动 appium-remote-debugger

在上面已经介绍过,通过以下命令启动 appium-remote-debugger:

启动成功后,会显示以下信息:

第二步:设置手机

设置手机需要连接到同一个网络环境中,可以通过以下命令将手机连接到 appium-remote-debugger:

Android

iOS

其中,device_udid 是设备的 UDID,可以通过以下命令查看:

连接成功后,打开手机上的应用程序并启动 appium-remote-debugger,即可在 PC 端通过 Chrome 的 devtools 远程调试了。

示例代码

以下是一个示例代码,通过 appium-remote-debugger 获取页面的 HTML 内容:

-- -------------------- ---- -------
----- ------- - ---------------------------

----- -------- ---------------- -
  ----- ------------------------ - -----------------------------

  -- --------
  ----- -------- - ----- -------------
    ---- -------------------------
    ----- -----
  ---
  ----- ------ - --------------
    ------ -- ----------- --- ------ -- ---------------------------
  --
  -- --------- -
    ----- --- --------- ---- ----- --- ---------
  -

  -- --------
  ----- - -------------------- - - -------
  ----- ------ - ----- -----------------------
    ------- ---------------------
  ---
  ----- - ----- - ---------- ---- - - - ----- -------------------------
  ----- ---------------
  ------ -----
-

----------------------------------------------- -- -
  ------------------
---
展开代码

总结

appium-remote-debugger 是一款非常实用的调试工具,能够让我们在 PC 端通过 Chrome 的 devtools 远程调试 Android 或 iOS 设备上的应用。通过本文的介绍,相信大家已经掌握了 appium-remote-debugger 的基本使用方法,可以在开发过程中更加高效地进行调试操作。

来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/5f68b1e6a9b7065299ccb7cb

纠错
反馈

纠错反馈