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/getAddressAtPosition.js

26 lines
642 B

const EventEmitter = require('events')
class GetAddressAtPosition extends EventEmitter {
command (index, cb) {
this.api.perform((done) => {
getAddressAtPosition(this.api, index, (pos) => {
done()
cb(pos)
this.emit('complete')
})
})
return this
}
}
function getAddressAtPosition (browser, index, callback) {
index = index + 2
browser.execute(function (index) {
return document.querySelector('.instance:nth-of-type(' + index + ')').getAttribute('id').replace('instance', '')
}, [index], function (result) {
callback(result.value)
})
}
module.exports = GetAddressAtPosition