Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sauceaaron/f17bd6ceca6d01976c84a95731ba8fc3 to your computer and use it in GitHub Desktop.
Save sauceaaron/f17bd6ceca6d01976c84a95731ba8fc3 to your computer and use it in GitHub Desktop.
describe('Protractor Test', function()
{
var addField = element(by.css('[placeholder="add new todo here"]'));
var checkedBox = element(by.model('todo.done'));
var addButton = element(by.css('[value="add"]'));
beforeEach(function() {
annotate("starting test");
});
var spec = it('should add a todo', function()
{
setTestName(spec);
browser.get('https://angularjs.org/');
moveTo(addField);
addField.isDisplayed();
browserLog("hello there");
browser.executeScript("console.log(angular)");
browser.manage().logs().get("browser").then(log => console.log('browserlog: ', log));
annotate("creating new task");
addField.sendKeys('New Task');
addButton.click();
passTest();
});
});
function moveTo(element)
{
browser.executeScript("arguments[0].scrollIntoViewIfNeeded();", element.getWebElement());
}
function browserLog(message)
{
browser.executeScript("console.log(\"" + message + "\")");
}
function annotate(message)
{
browser.executeScript("sauce:context=" + message);
}
function setTestName(spec)
{
browser.executeScript("sauce:job-name=" + spec.getFullName());
}
function passTest(spec)
{
browser.executeScript("job-result=passed"));
}
function failTest(spec)
{
browser.executeScript("job-result=failed"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment