Last active
June 21, 2018 20:16
-
-
Save sauceaaron/f17bd6ceca6d01976c84a95731ba8fc3 to your computer and use it in GitHub Desktop.
Annotate tests with Sauce Javascript Executor: https://wiki.saucelabs.com/display/DOCS/Annotating+Tests+with+Selenium%27s+JavaScript+Executor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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