diff --git a/lib/chrome.js b/lib/chrome.js index cef740c..8a656d3 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -161,7 +161,6 @@ var ChromeObject = function() { if (!this.userDataDir) { this.userDataDir = SHELL.getPathOfMyDocuments() + "\\UserData_Chrome_" + this.profileName; } - var shell = SHELL.create().setWorkingDirectory(this.workingDirectory); var process = shell.createProcess([ "\"" + this.binPath + "\"", @@ -340,7 +339,11 @@ var ChromeObject = function() { } } }; - + + this.scrollToBottom = function() { + return this.evaluate('window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight)'); + }; + this.focusWithoutActivate = function() { if (this.debuggingPort > 0) { try { @@ -464,10 +467,20 @@ var ChromeObject = function() { var page = this.getPageById(this.pageId); return page.url; }; - + this.triggerEvent = function(eventName, selector) { return this.evaluate('document.querySelector("' + selector + '").dispatchEvent(new Event("' + eventName + '"))'); }; + + this.scrollBy = function(dx, dy) { + var dx = (typeof(dx) !== "undefined" ? dx : '0'); + var dy = (typeof(dy) !== "undefined" ? dy : '0'); + return this.evaluate('window.scrollBy(' + dx + ', ' + dy + ')'); + }; + + this.reload = function() { + return this.sendPageRPC("Page.reload", {}); + }; this.create(); };