diff --git a/lib/chrome.js b/lib/chrome.js index 3be1448..d868b49 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -318,11 +318,12 @@ var ChromeObject = function() { this.close = function() { return this.sendPageRPC("Browser.close", {}); }; - + this.terminate = function() { - var pageList = this.pageList; - for (var i = 0; i < pageList.length; i++) { - this.oAutoIt.WinKill(pageList[i].title); + try { + this.oAutoIt.WinKill(this.pageId); + } catch (e) { + console.error("ChromeObject.terminate() -> " + e.message); } }; @@ -338,7 +339,7 @@ var ChromeObject = function() { // change webpage title to original this.setTitle(_title); } catch (e) { - console.error("ChromeObject.focus() -> " + e.message); + console.error("ChromeObject._focus() -> " + e.message); } } }; @@ -506,11 +507,15 @@ var ChromeObject = function() { this.reload = function() { return this.sendPageRPC("Page.reload", {}); }; - + this.hasClass = function(selector, className) { var result = this.getEvaluatedValue('document.querySelector(".html5-video-player").getAttribute("class")'); - var classNames = result.split(' '); - return (classNames.indexOf(className) > -1); + if (result) { + var classNames = result.split(' '); + return (classNames.indexOf(className) > -1); + } else { + return false; + } }; this.create();