2018-11-22 04:58:45 +08:00
|
|
|
const e = require('./elements');
|
2018-11-24 03:18:05 +08:00
|
|
|
const ce = require('../core/elements');
|
2018-11-22 04:58:45 +08:00
|
|
|
|
|
|
|
async function openChat(test) {
|
2018-11-24 03:18:05 +08:00
|
|
|
// TODO: Check this if it's open before click
|
|
|
|
await test.click(ce.userList);
|
|
|
|
await test.click(e.chatButton,true);
|
2018-11-23 22:43:35 +08:00
|
|
|
await test.waitForSelector(e.chatBox);
|
|
|
|
await test.waitForSelector(e.chatMessages);
|
2018-11-22 04:58:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async function getTestElements(test) {
|
|
|
|
const messages = await test.page.evaluate((chat) => {
|
|
|
|
const messages = [];
|
|
|
|
const children = document.querySelector(chat).childNodes;
|
|
|
|
for (let i = 0; i < children.length; i++) {
|
|
|
|
let content = children[i].childNodes[0].childNodes[1];
|
|
|
|
if (content) {
|
|
|
|
content = content.childNodes;
|
|
|
|
messages.push({ name: content[0].innerText, message: content[1].innerText });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(messages);
|
|
|
|
return messages;
|
|
|
|
}, e.chatMessages);
|
|
|
|
|
|
|
|
return messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.openChat = openChat;
|
|
|
|
exports.getTestElements = getTestElements;
|