错误:无法捕获屏幕截图

编程入门 行业动态 更新时间:2024-10-23 18:24:14
错误:无法捕获屏幕截图 - 使用Protractor和Appium的Android混合应用程序(Error: Unable to capture screenshot - Android hybrid app using Protractor and Appium)

我正在使用Protractor进行测试自动化。 我使用Protractor(jasmine)和Appium完美地测试了我的混合Android应用程序。 但是我无法让browser.takeScreenshot()函数正常工作。 所有其他测试工作完全像点击按钮或类似的东西。 我创建了一个新的空白应用程序,以排除插件导致此问题。 没有Cordova插件阻止屏幕截图功能,我可以使用Android设备本身截取屏幕截图。 我尝试了这个StackOverflow的答案(以及更多),但没有成功(似乎没有人经历过这个问题)。 我还使用了protractor-jasmin2-screenshot-reporter排除了我的截屏代码无法正常工作,但我得到了相同的结果。 令人沮丧的是,当我使用browserName:'Chrome'并让测试在我的设备上打开Chrome并打电话给www.google.com并让我的代码截图时,它运行正常。 只有在我的混合应用程序中,截取屏幕截图不起作用。 ( browser.takeScreenshot().then(function (png) {...代码来自官方量角器页面和其他可靠来源)。

我的规格

量角器:5.0.0 Appium(桌面客户端):1.4.16.1(最新版本) Windows 10企业版64位 Chromedriver:2.27(最新版本) 角度:1.5.3 Node.js:6.9.1 Android:6.0.1和4.4.2(Galaxy S6和Alcatel Pixi) 科尔多瓦6.4.0

我的量角器config.js

exports.config = { seleniumAddress : 'http://localhost:4723/wd/hub', // Reference: https://github.com/appium/sample-code/blob/master/sample-code/examples/node/helpers/caps.js capabilities : { // needed by local appium platformVersion : '', platformName : '', deviceName : '', // needed by protractor browserName : '', autoWebview : true, // CHANGE THIS TO YOUR ABSOLUTE PATH OR SET IT IN APPIUM CLIENT app : 'C:/Projekte/WifiWizardTestApp/platforms/android/build/outputs/apk/android-debug.apk', newCommandTimeout : 60 }, //needed for local appium baseUrl : 'http://localhost:8080', //configuring wd in onPrepare //wdBridge helps to bridge wd driver with other selenium clients //See https://github.com/sebv/wd-bridge/blob/master/README.md onPrepare : function () { var wd = require('wd'); var protractor = require('protractor'); var wdBridge = require('wd-bridge')(protractor, wd); wdBridge.initFromProtractor(exports.config); }, };

我的test.spec.js

var fs = require('fs'); describe('Testing the browse state', function () { it('should be able to take a screenshot', function (done) { browser.sleep(2000); browser.takeScreenshot().then(function (png) { console.log('browser.takeScreenshot()'); var stream = fs.createWriteStream('screenshot.png'); stream.write(new Buffer(png, 'base64')); stream.end(); done(); }); }); it('should be able to take an other screenshot', function () { browser.takeScreenshot().then(function (png) { console.log('browser.takeScreenshot()'); var stream = fs.createWriteStream('screenshot2.png'); stream.write(new Buffer(png, 'base64')); stream.end(); }); }); });

我的控制台输出(Android 6.0.1)

C:\Projekte\WifiWizardTestApp>protractor protractor.config.js --specs tests/browse.spec.js [09:27:44] I/hosted - Using the selenium server at http://localhost:4723/wd/hub [09:27:44] I/launcher - Running 1 instances of WebDriver Started A Jasmine spec timed out. Resetting the WebDriver Control Flow. FA Jasmine spec timed out. Resetting the WebDriver Control Flow. F Failures: 1) Testing the browse state should be able to take a screenshot Message: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Stack: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5) 2) Testing the browse state should be able to take an other screenshot Message: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Stack: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5) 2 specs, 2 failures Finished in 60.04 seconds

我的控制台输出(Android 4.4.2)

C:\Projekte\WifiWizardTestApp>protractor protractor.config.js --specs tests/browse.spec.js [15:15:49] I/hosted - Using the selenium server at http://localhost:4723/wd/hub [15:15:49] I/launcher - Running 1 instances of WebDriver Started FF Failures: 1) Testing the browse state should be able to take a screenshot Message: Failed: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) Stack: WebDriverError: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) at WebDriverError (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5) at Object.checkLegacyResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15) at parseHttpResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13) at doSend.then.response (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13) at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: WebDriver.takeScreenshot() at WebDriver.schedule (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:816:17) at WebDriver.takeScreenshot (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1092:17) at ProtractorBrowser.to.(anonymous function) [as takeScreenshot] (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\lib\browser.ts:94:25) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:14:17) at C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:98:15 at new ManagedPromise (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1067:7) at controlFlowExecute (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:87:18) at TaskQueue.execute_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2970:14) at TaskQueue.executeNext_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2953:27) at asyncRun (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2813:27) From: Task: Run it("should be able to take a screenshot") in control flow at Object.<anonymous> (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:86:14) From asynchronous test: Error at Suite.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:8:5) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:4:1) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) 2) Testing the browse state should be able to take an other screenshot Message: Failed: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) Stack: WebDriverError: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) at WebDriverError (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5) at Object.checkLegacyResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15) at parseHttpResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13) at doSend.then.response (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13) at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: WebDriver.takeScreenshot() at WebDriver.schedule (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:816:17) at WebDriver.takeScreenshot (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1092:17) at ProtractorBrowser.to.(anonymous function) [as takeScreenshot] (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\lib\browser.ts:94:25) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:26:17) at C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:102:25 at new ManagedPromise (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1067:7) at controlFlowExecute (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:87:18) at TaskQueue.execute_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2970:14) at TaskQueue.executeNext_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2953:27) at asyncRun (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2860:25) From: Task: Run it("should be able to take an other screenshot") in control flow at Object.<anonymous> (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:86:14) From asynchronous test: Error at Suite.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:24:5) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:4:1) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) 2 specs, 2 failures Finished in 2.258 seconds [15:17:49] I/launcher - 0 instance(s) of WebDriver still running [15:17:49] I/launcher - #01 failed 2 test(s) [15:17:49] I/launcher - overall: 2 failed spec(s) [15:17:49] E/launcher - Process exited with error code 1

I'm using Protractor for test automation. I tested my hybrid Android app perfectly using Protractor (jasmine) and Appium. But I can not get the browser.takeScreenshot() function to work properly. All other test work perfectly like clicking buttons or stuff like that. I created a new blank app to rule out that a plugin causes this problem. No Cordova Plugin prevents the screenshot capability and I am able to take screenshots with the android device itself. I tried this StackOverflow answer (and many many more), but with no success (and it seems like nobody ever experienced this issue). I also used the protractor-jasmin2-screenshot-reporter to rule out, that my code for taking the screenshot is not working, but I get the same result. Intresstingly, when I use browserName: 'Chrome' and let the test open Chrome on my device and call www.google.com and let my code take a screenshot, it works fine. Only in my hybrid app, taking a screenshot does not work. (The browser.takeScreenshot().then(function (png) {... code is from the official protractor page and other reliable sources).

My Specs

Protractor: 5.0.0 Appium (Desktop Client): 1.4.16.1 (latest version) Windows 10 Enterprise 64 Bit Chromedriver: 2.27 (latest version) Angular: 1.5.3 Node.js: 6.9.1 Android: 6.0.1 and 4.4.2 (Galaxy S6 and Alcatel Pixi) Cordova 6.4.0

My Protractor config.js

exports.config = { seleniumAddress : 'http://localhost:4723/wd/hub', // Reference: https://github.com/appium/sample-code/blob/master/sample-code/examples/node/helpers/caps.js capabilities : { // needed by local appium platformVersion : '', platformName : '', deviceName : '', // needed by protractor browserName : '', autoWebview : true, // CHANGE THIS TO YOUR ABSOLUTE PATH OR SET IT IN APPIUM CLIENT app : 'C:/Projekte/WifiWizardTestApp/platforms/android/build/outputs/apk/android-debug.apk', newCommandTimeout : 60 }, //needed for local appium baseUrl : 'http://localhost:8080', //configuring wd in onPrepare //wdBridge helps to bridge wd driver with other selenium clients //See https://github.com/sebv/wd-bridge/blob/master/README.md onPrepare : function () { var wd = require('wd'); var protractor = require('protractor'); var wdBridge = require('wd-bridge')(protractor, wd); wdBridge.initFromProtractor(exports.config); }, };

My test.spec.js

var fs = require('fs'); describe('Testing the browse state', function () { it('should be able to take a screenshot', function (done) { browser.sleep(2000); browser.takeScreenshot().then(function (png) { console.log('browser.takeScreenshot()'); var stream = fs.createWriteStream('screenshot.png'); stream.write(new Buffer(png, 'base64')); stream.end(); done(); }); }); it('should be able to take an other screenshot', function () { browser.takeScreenshot().then(function (png) { console.log('browser.takeScreenshot()'); var stream = fs.createWriteStream('screenshot2.png'); stream.write(new Buffer(png, 'base64')); stream.end(); }); }); });

My console output (Android 6.0.1)

C:\Projekte\WifiWizardTestApp>protractor protractor.config.js --specs tests/browse.spec.js [09:27:44] I/hosted - Using the selenium server at http://localhost:4723/wd/hub [09:27:44] I/launcher - Running 1 instances of WebDriver Started A Jasmine spec timed out. Resetting the WebDriver Control Flow. FA Jasmine spec timed out. Resetting the WebDriver Control Flow. F Failures: 1) Testing the browse state should be able to take a screenshot Message: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Stack: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5) 2) Testing the browse state should be able to take an other screenshot Message: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Stack: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5) 2 specs, 2 failures Finished in 60.04 seconds

My console output (Android 4.4.2)

C:\Projekte\WifiWizardTestApp>protractor protractor.config.js --specs tests/browse.spec.js [15:15:49] I/hosted - Using the selenium server at http://localhost:4723/wd/hub [15:15:49] I/launcher - Running 1 instances of WebDriver Started FF Failures: 1) Testing the browse state should be able to take a screenshot Message: Failed: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) Stack: WebDriverError: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) at WebDriverError (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5) at Object.checkLegacyResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15) at parseHttpResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13) at doSend.then.response (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13) at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: WebDriver.takeScreenshot() at WebDriver.schedule (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:816:17) at WebDriver.takeScreenshot (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1092:17) at ProtractorBrowser.to.(anonymous function) [as takeScreenshot] (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\lib\browser.ts:94:25) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:14:17) at C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:98:15 at new ManagedPromise (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1067:7) at controlFlowExecute (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:87:18) at TaskQueue.execute_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2970:14) at TaskQueue.executeNext_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2953:27) at asyncRun (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2813:27) From: Task: Run it("should be able to take a screenshot") in control flow at Object.<anonymous> (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:86:14) From asynchronous test: Error at Suite.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:8:5) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:4:1) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) 2) Testing the browse state should be able to take an other screenshot Message: Failed: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) Stack: WebDriverError: unknown error: unhandled inspector error: {"code":-32603,"message":"Unable to capture screenshot"} (Session info: webview=30.0.0.0) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) at WebDriverError (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5) at Object.checkLegacyResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15) at parseHttpResponse (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13) at doSend.then.response (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13) at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: WebDriver.takeScreenshot() at WebDriver.schedule (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:816:17) at WebDriver.takeScreenshot (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:1092:17) at ProtractorBrowser.to.(anonymous function) [as takeScreenshot] (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\lib\browser.ts:94:25) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:26:17) at C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:102:25 at new ManagedPromise (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1067:7) at controlFlowExecute (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:87:18) at TaskQueue.execute_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2970:14) at TaskQueue.executeNext_ (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2953:27) at asyncRun (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2860:25) From: Task: Run it("should be able to take an other screenshot") in control flow at Object.<anonymous> (C:\Users\mkaiser\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:86:14) From asynchronous test: Error at Suite.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:24:5) at Object.<anonymous> (C:\Projekte\WifiWizardTestApp\tests\browse.spec.js:4:1) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) 2 specs, 2 failures Finished in 2.258 seconds [15:17:49] I/launcher - 0 instance(s) of WebDriver still running [15:17:49] I/launcher - #01 failed 2 test(s) [15:17:49] I/launcher - overall: 2 failed spec(s) [15:17:49] E/launcher - Process exited with error code 1

最满意答案

wdBrowser.context('NATIVE_APP').then(() => { browser.takeScreenshot().then(function (png) { console.log('browser.takeScreenshot()'); var stream = fs.createWriteStream('screenshot.png'); stream.write(new Buffer(png, 'base64')); stream.end(function(){ wdBrowser.context(<Your webview>).then(done); }); }) });

其中wdBrowser是由wdBridge设置的全局变量。 应该工作 - 一直有类似的问题(无法截屏但没有像你一样的错误信息)

您可以从appium日志中获取您的webview名称/ ID。

wdBrowser.context('NATIVE_APP').then(() => { browser.takeScreenshot().then(function (png) { console.log('browser.takeScreenshot()'); var stream = fs.createWriteStream('screenshot.png'); stream.write(new Buffer(png, 'base64')); stream.end(function(){ wdBrowser.context(<Your webview>).then(done); }); }) });

Where wdBrowser is a global variable set by wdBridge. Should work - been having a similar issue (unable to take screenshot but no error message like you have)

You can grab your webview name/id from the appium logs.

更多推荐

本文发布于:2023-04-29 03:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334559.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:截图   屏幕   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!