Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const { By } = require('selenium-webdriver');
const stampit = require('stampit');
const TodoListItem = require('./todo-list-item.page');
const TodoList = stampit
.statics({
completeListId: 'completed',
todoListId: 'todo',
})
.init(function ({ webElement }) {
this.isComplete = async function isComplete() {
return (await webElement.getAttribute('id')) === TodoList.completeListId;
};
this.isTodo = async function isTodo() {
return (await webElement.getAttribute('id')) === TodoList.todoListId;
};
this.getItems = async function getItems() {
const items = await webElement.findElements(By.css('li'));
this.isEnabled = async function isEnabled() {
const element = await findElement();
return element.isEnabled();
};
this.click = async function click() {
const element = await findElement();
return element.click();
};
});
const TodoListItemCreator = stampit
.statics({
AddButton,
})
.init(function ({ driver }) {
const findElement = async () => driver.findElement(By.css('header input'));
this.focus = async function focus() {
const element = await findElement();
return element.sendKeys('');
};
this.sendKeys = async function sendKeys(...keys) {
const element = await findElement();
return element.sendKeys(...keys);