From f9266b5dfe168b4a1d93847290cacebcd4773455 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Tue, 20 May 2014 12:27:21 -0400 Subject: [PATCH] Check exists before read file --- lib/devices/android/android-controller.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/devices/android/android-controller.js b/lib/devices/android/android-controller.js index 7cc72bea1..ebdcf5517 100644 --- a/lib/devices/android/android-controller.js +++ b/lib/devices/android/android-controller.js @@ -375,8 +375,11 @@ androidController.getPageSource = function (cb) { // Top level cb function (err) { if (err) return cb(err); - var xml = fs.readFileSync(xmlFile, 'utf8'); - fs.unlinkSync(xmlFile); + var xml = ''; + if (fs.existsSync(xmlFile)) { + xml = fs.readFileSync(xmlFile, 'utf8'); + fs.unlinkSync(xmlFile); + } try { xml = _updateSourceXMLNodeNames(xml); } catch (e) {