remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
remix-project/test-browser/commands/switchBrowserWindow.js

26 lines
653 B

const EventEmitter = require('events')
class SwitchBrowserWindow extends EventEmitter {
command (url, windowName, cb) {
this.api.perform((done) => {
switchWindow(this.api, url, windowName, cb)
done()
this.emit('complete')
})
return this
}
}
function switchWindow (browser, url, windowName, cb) {
browser.execute(function (windowName) {
return window.open('', windowName, 'width=2560, height=1440')
}, [windowName], (newWindow) => {
browser.switchWindow(windowName)
.url(url)
.pause(5000)
.assert.urlContains(url)
if (cb) cb(browser, newWindow)
})
}
module.exports = SwitchBrowserWindow