parent
e3d2e24d67
commit
cc6abca223
@ -0,0 +1,21 @@ |
||||
const EventEmitter = require('events') |
||||
|
||||
// fix for editor scroll
|
||||
class ScrollEditor extends EventEmitter { |
||||
command (direction, numberOfTimes) { |
||||
const browser = this.api |
||||
|
||||
browser.waitForElementPresent('.ace_text-input') |
||||
for (let i=0; i<numberOfTimes; i++){ |
||||
if (direction.toLowerCase() === 'up') browser.sendKeys('.ace_text-input', browser.Keys.ARROW_UP) |
||||
if (direction.toLowerCase() === 'down') browser.sendKeys('.ace_text-input', browser.Keys.ARROW_DOWN) |
||||
} |
||||
browser.perform((done) => { |
||||
done() |
||||
this.emit('complete') |
||||
}) |
||||
return this |
||||
} |
||||
} |
||||
|
||||
module.exports = ScrollEditor |
@ -1,25 +0,0 @@ |
||||
const EventEmitter = require('events') |
||||
|
||||
class ScrollUp extends EventEmitter { |
||||
command (target, height) { |
||||
this.api.perform((done) => { |
||||
_scrollUp(this.api, target, height, () => { |
||||
done() |
||||
this.emit('complete') |
||||
}) |
||||
}) |
||||
return this |
||||
} |
||||
} |
||||
|
||||
function _scrollUp (browser, target, height, cb) { |
||||
browser.execute(function (target, height) { |
||||
const element = document.querySelector(target) |
||||
|
||||
element.scrollTop = element.scrollHeight - height |
||||
}, [target, height], function () { |
||||
cb() |
||||
}) |
||||
} |
||||
|
||||
module.exports = ScrollUp |
Loading…
Reference in new issue