diff --git a/lib/chrome.js b/lib/chrome.js index f78bdcb..520b4ed 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -511,15 +511,26 @@ var ChromeObject = function() { return this.sendPageRPC("Page.reload", {}); }; - this.hasClass = function(selector, className) { - var result = this.getEvaluatedValue('document.querySelector(".html5-video-player").getAttribute("class")'); - if (result) { - var classNames = result.split(' '); - return (classNames.indexOf(className) > -1); - } else { - return false; + this.hasClass = function(seletctor, className) { + try { + var result = this.getEvaluatedValue('document.querySelector(".html5-video-player").getAttribute("class")'); + if (typeof(result) === "string") { + return (result.split(' ').indexOf(className) > -1); + } else { + return false; + } + } catch (e) { + console.error("ChromeObject.hasClass() -> " + e.message); } }; + + this.getAttribute = function(selector, attributeName) { + return this.getEvaluatedValue('document.querySelector("' + selector + '").getAttribute("' + attributeName + '")'); + }; + + this.sendSpaceKey = function() { + this.oAutoIt.Send("{SPACE}"); + }; this.create(); };