問題
1. error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress

之前的會話沒有關閉,然后你又運行了測試實例,也沒有設置覆蓋.
解決:
1. 重新停止appium服務,開啟Appium服務
2. 在Genarel Setting那里設置覆蓋Session,重啟Appium
測試結束在AfterClass加driver.quit()
-------------------------------------------------------------------------------------
2. error: Failed to start an Appium session, err was: Error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk-windows\platform-tools\adb.exe -s adb server version (32) doesn't match this client (36); killing…
wait-for-device"
error: could not install smartsocket listener: cannot bind to 127.0.0.1:5037:

沒有鏈接上手機或者模擬器,請確認已經連接成功,重新鏈接
-------------------------------------------------------------------------
3. error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.

手機系統低於4.2,appium不支持4.2.2以下的系統,請換一個手機或者模擬器來測試。
------------------------------------------------------------------------------------
4. Error: Permission to start activity denied.

**activity在清單文件里面沒添加Android:exported="true"的話,你不能直接打開對應的activity,需要從啟動頁activity打開。
exported屬性就是設置是否允許activity被其它程序調用**
--------------------------------------------------------------------------------------------------------------------
5. error: Failed to start an Appium session, err was: Error: Activity used to start app doesn't exist or cannot ve launched! Make usre it exists and is launchable activity

要打開的activity不存在,activity路徑錯誤,改為完整正確的activity路徑
----------------------------------------------------------------------------------
6. error: Failed to start an Appium session, err was: Error: 'java - version' failed. Error: Command failed: C:\Windows\system32\cmd.exe /s /c "java -version"

Java
版本錯誤,請安裝最新的版本。
-----------------------------------------------------------------------------------
7.> info: [debug] Error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk-windows\platform-tools\adb.exe -s 8806a0b0 shell "echo 'ready'"error: unknown host service

鏈接手機失敗,重新鏈接手機即可,我就是重新拔插了一下usb
Error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk-windows\platform-tools\adb.exe -s 8806a0b0 shell "echo 'ping'""
error: unknown host service
adb被突然占用導致,例如你在運行用例的時候運行了模擬器。
-----------------------------------------------------------------------------------------------------------------
8. UIAutomatorViewer提示: Unable to connect to adb. Check if adb is installed correctly
解決,sdk升級到了25產生的問題。
解決方法:
- 將adb.exe 復制一份到uiautomatorviewer.bat 目錄下
- 修改uiautomatorviewer.bat文件最后一行(改binddir=%prog_dir%為自己的platform-tools本地路徑)

9 error: Failed to start an Appium session, err was:INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling
When you are at final step to execute test automation script for mobile app testing on a mobile emulator or a virtual device or a real device, you might observe that script execution fails with different kinds of errors, In context to current article you will look at the error and solutions for: INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.
Error in Appium Server:

Error in Android studio run console:

For the first time when you execute the script it might pass, but it will fail with above error when you try to execute the same or any other script multiple times. Or when your test script execution fails on the first attempt for some other reason, and when you fix it and execute it again, you might encounter this new issue.
原因:
The reason for this error is that Appium installs 2 mobile applications before executing the script.
1. io.appium.settings
2. io.appium.unlock
These are the supportive mobile applications appium utilizes to execute the test automation script in Mobile Emulator or virtual device or a real mobile device.
Ideally Appium should remove these files every time at the end of the script execution or termination, if it is intends to install them every time a script is executed, or it should conditionally install these apps / apks to the mobile emulator or mobile device.
In your mobile emulator / Virtual Device / Real device, the 2 mobile applications appear as below:


There are multiple ways to troubleshoot this error and go ahead for a successful test script execution.
解決辦法
Solution 1: ADB's uninstall command to remove the files.
You can open command prompt, assuming that you already had set the environment variables for ANDROID_HOME and Path variables for sdk tools and platform tools.
And execute commands as shown below:
Solution 2: Uninstall manually
You can open the mobile emulator / virtual device / real device and go to apps and uninstall them.
Solution 3: Write code as part of your test automation script.
As part of your selenium test automation script, you could write instructions to execute the commands provided in solution 1 above, so that this issue would not arise.
Hope this article has been helpful and you are able to proceed further with script execution.
Request to kindly share any of your queries in form of comments, we would try our best to provide any solution for you.
------------------------------------------------------------------------------------------------------------
10. 出錯信息里含有"ps 'uiautomator',具體信息未 A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "C:\Users\sxie\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'""
android-appium: A new session could not be created
detail log:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "C:\Users\sxie\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'""
) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'WL00070299', ip: '10.110.12.39', os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_40'
Driver info: driver.version: AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:161)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:76)
at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:111)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:112)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:73)
at com.sky.demo.ContactTest.setUp(ContactTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
==========================================
直接在cmd中執行"C:\Windows\system32\cmd.exe /s /c "C:\Users\sxie\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'""
bad pid 'uiautomator'", 報錯: bad pid 'uiautomator'
代碼內容為
public class ContactTest {
private AndroidDriver driver;
@Before
public void setUp() throws Exception {
//設置apk的路徑
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "ContactManager.apk");
- //設置自動化相關參數
- DesiredCapabilities capabilities = new DesiredCapabilities();
- capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
- capabilities.setCapability("automationName","Appium");
- capabilities.setCapability("platformName", "Android");
- capabilities.setCapability("deviceName", "Pixel_XL_API_25");// Galaxy_Nexus_API_25
- capabilities.setCapability("noReset", true);
- capabilities.setCapability("avdReadyTimeout", 300000);
- capabilities.setCapability("sessionOverride", true);
- //設置安卓系統版本
- capabilities.setCapability("platformVersion", "7.1.1");
- //設置apk路徑
- capabilities.setCapability("app", app.getAbsolutePath());
- //設置app的主包名和主類名
- capabilities.setCapability("appPackage", "com.example.android.contactmanager");
- capabilities.setCapability("appActivity", ".ContactManager");
- //初始化
- driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
- driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
- }
- @Test
- public void addContact(){
- WebElement el = driver.findElement(By.name("Add Contact"));
- el.click();
- List<WebElement> textFieldsList = driver.findElementsByClassName("android.widget.EditText");
- textFieldsList.get(0).sendKeys("feimaoyuzhubaobao");
- textFieldsList.get(2).sendKeys("forever together");
- driver.swipe(100, 500, 100, 100, 2);
- driver.findElementByName("Save").click();
- }
- @After
- public void tearDown() throws Exception {
- driver.quit();
- }
}
解決辦法:
resolved by this way:
adb.js(C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js) 中1035 行this.shell("ps '" + name + "'", function (err, stdout) {
對應執行的指令是ps 'uiautomator', Android7不支持這個指令格式,所以執行結果是bad pid 'uiautomator'
目前Appium未對此進行處理,所以需要修改此指令的執行方式
即將
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
替換成
this.shell_grep("ps", name, function (err, stdout) {
if (err) {
logger.debug("No matching processes found");
return cb(null, []);
}
並增加上面用到的shell_grep函數:
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};
---------------------------------------------------------------------------------------------------------------------
11.Android 7.0系統的手機無法執行appium腳本的問題
Appium Appium 版本 1.4.16,Android 設備固件 7.x,執行腳本時,報錯使用語言:python報錯如下:
WebDriverException: Message: A new session could not be created. (Original error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"])
這個是因為appium版本1.4.16 使用的 uiatumator1.0不支持的原因導致?如果不升級appium版本,是否有解決方案?
解決辦法
uiautomator1.0應該是不支持7.0,不升版本就換用uiautomator2.0吧,或者用下面的改腳本的方法使用。
解決Android 7.0系統的手機無法執行appium腳本的問題,改問題的具體解決方法如下:
- 找到appium的安裝目錄下的adb.js文件,windows版本的目錄如下:Appium\node_modules\appium\node_modules\appium-adb\lib
2、 打開adb.js,手動修改該文件下的內容,此方法我已經試驗成功。
adb.js 中1035 行this.shell("ps '" + name + "'", function (err, stdout) {
對應執行的指令是ps 'uiautomator', Android7不支持這個指令格式,所以執行結果是bad pid 'uiautomator'
目前Appium未對此進行處理,所以需要修改此指令的執行方式
即將
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
替換成
this.shell_grep("ps", name, function (err, stdout) {
if (err) {
logger.debug("No matching processes found");
return cb(null, []);
}
並增加上面用到的shell_grep函數:
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};
- 網上還有如下的修改解決辦法:以下我未試驗。
ADB.prototype.getPIDsByName = function (name, cb) {
logger.debug("Getting all processes with '" + name + "'");
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
stdout = stdout.trim();
var procs = [];
var outlines = stdout.split("\n");
outlines.shift(); //在該處添加此行代碼
3、重啟appium
-------------------------------------------------------------------------------------------------------------------------------------
12、:WARN AppiumDoctor ✖ Bin directory for $JAVA_HOME is not set.
這個問題困擾了我兩天,搜索各個網站無果,求助各個所謂的測試交流群(原來大家都是在里面胡聊)無人幫助回答,無奈翻牆至國外搜尋答案解決問題:
解決辦法:You can try setting the .bash_profile as well and you can try to set JAVA_HOME variable like this :
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
重啟電腦即可。
if not,please try:
export PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin
To verify that all of Appium's dependencies are met you can use appium-doctor
翻譯:為了驗證Appium的所有依賴項是否滿足,您可以使用Appium - doctor
13、Message: Parameters were incorrect. We wanted {"required":["value"]} and you sent ["text","sessionId","id","value"]
在執行腳本的時候會報這樣一個錯誤,這個問題是因為selenium版本過高,和1.6.5的Appium不兼容。需要把selenium版本降到3.3.1或者2.53.1就行了。
查看selenium版本方法:在終端進入到Python的命令行狀態
>>>import selenium
>>>help(selenium)
輸入以上兩行命令就可查看當前selenium版本。
更換selenium版本方法:
pip3 uninstall selenium
pip3 install selenium==3.3.1 #注意,==兩邊沒有空格
解釋:這里使用pip3而不是pip,是因為我的電腦Xcode里有一個自帶的2.7版本,而我又安裝了一個3.6版本的。pip3是指卸載了我安裝的Python3.6版本的Selenium,而我每次都會使用Python3.6,而不是系統自帶的Python2.7.如果使用pip,則改變的是系統自帶的selenium。
14:HTMLTestRunner.py文件本身報的幾個錯誤
在使用Appium的時候往往我們需要生成直觀的測試報告,這時候就需要使用到
HTMLTestRunner.py文件(這是官網)。但是這個文件5年前就已經不更新了,那時候用的還是Python2,現在大多已經使用了Python3了,所以就導致了一些問題的產生。目前報錯是5處,我們需要對官網提供的這個HTMLTestRunner.py文件做5處修改。網上也可以查到需要修改的地方,但是都不是很准確,這里我提供一個
修改之后的,修改之處我都做了注釋,可以看到修改前和修改后的區別。
這個問題我是在使用HTMLTestRunner的時候產生的,原因就是打開文件的方式錯誤造成的,造成的后果就是生成的測試報告是空的。在打開文件的時候開始的時候(就是沒用HTMLTestRunner的時候,記住,
是在自己寫的執行腳本里,不是在HTMLTestRunner.py文件里)使用的是:open('HTMLReport.html', 'w') as f: 。這時候需要改成:open('HTMLReport.html', 'wb') as f:就可以了。(我也不太清楚原因是什么,網上有說文件打開的方式默認是二進制)
在這里我對Python的open函數做一個解釋,如果有不對的地方歡迎指正,在此感謝.
open(路徑+文件名,讀寫模式) #路徑名為可選,默認是當前路徑
解釋讀寫模式:r(read)只讀,r+讀寫,w(write)新建(會覆蓋原有文件),a(append)追加,b(binary)二進制文件
常用模式如:'rb','wb','r+b'等等
讀寫模式的類型有: rU或Ua 以讀方式打開,同時提供通用換行符支持(PEP 278) w 以寫方式打開 a 以追加模式打開(從EOF開始,必要時創建新文件) r+ 以讀寫模式打開 w+ 以讀寫模式打開(與a+的區別是該種方式會清空原有內容) a+ 以讀寫模式打開(參見a) ab 以二進制追加模式打開(參見a) rb+ 以二進制讀寫模式打開(參見r+) wb+ 以二進制讀寫模式打開(參見w+) ab+ 以二進制讀寫模式打開(參見a+)
16:Could not connect to lockdownd. Exiting.
解決辦法一,提高權限:
sudo chmod -R 777 /usr/local/lockdown/
解決辦法二,比較麻煩但是解決較徹底:
brew uninstall ideviceinstaller brew uninstall libimobiledevice brew install --HEAD libimobiledevice brew link --overwrite libimobiledevice brew install ideviceinstaller brew link --overwrite ideviceinstaller
17、 如何驗證Appium環境已經配置成功
首先需要安裝appium-doctor,然后再用appium-doctor驗證
npm install -g appium-doctor appium-doctor
18、Could not link: /usr/local/share/doc/homebrew
Please delete these paths and run brew update.
這個問題其實嚴格來說並不是Appium的問題,只是在解決Appium問題的時候會用到Homebrew,在更新brew(brew update)的時候報了這樣一個錯,原因就是:
Because you have files there already that we don't overwrite automatically in case they are important.
解決辦法就是把這個路徑delete,然后再update,方法如下:
rm -rf /usr/local/share/doc/homebrew
這是一個非常可怕的命令行,真的很恐怖,簡直就是數據終結者,我之所以會寫這篇文章就是錯誤的使用了
rm -rf,導致電腦上的數據全部被清空,那種感覺是絕望的,不得已重新配置Appium環境。
19、Carthage was NOT found!
這個問題是在你檢驗Appium配置是否成功的時候出現,解決這個問題比較簡單,安裝這個Carthage就好了,方法:
brew update brew install carthage
20、code65的錯誤

這個錯誤很常見,出現在用真機的時候,原因就是真機上沒有安裝WDA,只要把WDA裝到真機上就可以解決報錯。
21、未安裝ios-deploy的錯誤

解決這個問題很簡單,就按照截圖中的報錯提示:利用npm安裝ios-deploy就好了。
npm install -g ios-deploy
22、permission to start activity denied appium

這是在Android真機時發生的錯誤,別再到處找解決方案了,趕快找Android開發人員吧。讓他在項目里改一個屬性重新給你打一個包,就是這屬性限制了我們的測試:
exported = true這個屬性默認是false。
23、ImportError: No module named appium
在運行腳本的時候報這樣一個錯誤,原因是沒有安裝Appium Python Client,把這個安裝上就好了:
pip3 install Appium-Python-Client
如果這條命令報錯,請換:
pip3 install --user Appium-Python-Client
如果還報錯,就只有最后這個大法了,加sudo,sudo雖好,能不用則不用:
sudo pip3 install --user Appium-Python-Client
24、AttributeError: module 'appium.webdriver' has no attribute 'remote'
用了一段時間,同樣的步驟,竟然會有這樣的錯誤,當然了,腳本是錄制的。這個原因是錄制的腳本中remote應該寫成大寫開頭Remote就可以了。
25、 - Error occurred: ApplicationVerificationFailed
這個是當我們試圖通過終端命令
ideviceinstaller -i 包的路徑把App裝到真機上的時候出現的,原因是我們的包是模擬器包,只能在模擬器上安裝,需要讓開發人員打一個真機包才能使用。
26、命令行npm install -g appium 安裝appium報錯
明明是按照官網的教程來的,可是這一步就總是出錯,是不是很着急?這里有一個巨坑,npm版本如果是最新(5.3.0)的則無法安裝,會一直報錯,所以需要給npm降低版本:
npm install npm@4 -g
如果這一步出錯,那就需要先清除npm緩存:
npm cache clean
如果這一步也出錯,那就試試:
npm cache verify
然后再降低版本
27、各個測試環境的搭建
1、The
XCUITest Driver(for iOS apps)
2、The
UiAutomator2 Driver(for Android apps)
3、The
Windows Driver(for Windows Desktop apps)
4、The
Mac Driver(for Mac Desktop apps)
5、(BETA)The
Espresso Driver(for Android apps)
該問題來自官網文檔
Getting Started
28、怎么獲取 Android 應用的 appPackage 和 appActivity
電腦連接手機,打開 App
adb logcat | grep Displayed
或
adb logcat | grep ActivityManager
該問題答案來自
博客。
補充一個iPhone真機的Desired Capabilities截圖,希望能夠幫助有需要的朋友:

29、could not connect to server are you sure it's running?
出現這個問題的原因是 Server 選擇錯了。選的Customer Server, 換Automatic Server。如圖:

30、An unknown server-side error occurred while processing the command. Original error: Could not install app: 'Command 'ios-deploy --id a1d83b4118076a91c432a49b123d7e40e7302332 --bundle /Users/guxuecheng/Desktop/sample-code/sample-code/apps/TestApp/build/Release-iphonesimulator/TestApp-iphonesimulator.app' exited with code 253'
報這個錯的原因是因為測試用的安裝包只能安裝到模擬器上,如果試圖安裝到真機上就會報這個錯誤。
31、執行 Python 腳本如何選擇 Python 版本
這個問題一般出現在 Mac 上,因為系統自帶 Python2,而我們往往會再安裝一個 Python3.這樣在執行腳本的時候總是會默認使用 Python2,有時會導致腳本無法通過。只需要在腳本的頭部加一行代碼就可以了:
# !/usr/bin/python3
。在實際使用當中會報如下錯誤:
Cannot run program "/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6" (in directory "/Users/guxuecheng/Desktop/sample-code/sample-code/examples/python"): error=2, No such file or directory。
如圖:

-----------------------------------------------------------------------------------
32、driver.contexts 獲取H5信息,只能獲取NATIVE_APP,獲取不到webview
獲取不到webview是應為沒有獲取web權限,需要開發在代碼初始化的時候添加代碼:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
33、
本文內容總結來自: