I have a meteor app and want to retrieve some data inside a unit test from the client via a headless browser from webdriver.io.
The data I want is from this function:
Session.get()
-> http://meteortips.com/first-meteor-tutorial/sessions/
The headless browser I use is from below URL:
My test looks like this:
describe('[Check Boards]', () => {
it('should exist', () => {
const board = browser.execute('Session.get(\'currentBoard\')');
...
}
}
When i run this command Session.get('currentBoard')
inside a real browser console, I get the board as expected.
But when I run it from the code like described above inside a mocha test, I get this result:
{
"state": "success",
"sessionId": "12345",
"hCode": 12345,
"value": null,
"class": "org.openqa.selenium.remote.Response",
"_status": 0
}
The value is null, but there should be the board.
browser.execute
expects a function to run in the browser. You're passing in a string, so it probably doesn't know what to do. Here's an updated code snippet that should work:
describe('[Check Boards]', () => {
it('should exist', () => {
const board = browser.execute(function () {
return Session.get('currentBoard');
});
...
}
}