Protractor-sync builds on Protractor and provides:
hasClass
, closest
, and is
myElement.clear().sendKeys('text')
)Pre-reqs:
npm install asyncblock
)Install: npm install protractor-sync
import * as ab from 'asyncblock';
import { browserSync, configure, elementSync, polledExpect} from '../../app/index';
configure({ implicitWaitMs: 500 });
function createTest(fn: Function, errorMsg?: string) {
return (done: Function) => {
ab(() => {
fn();
}, (err: any) => {
if (errorMsg) {
expect(err.message).toEqual(errorMsg);
} else {
expect(err && err.stack || err || undefined).toBeUndefined();
}
done();
});
};
}
describe('Google Translate', () => {
const googleTranslateUrl = 'https://translate.google.com/';
it('does not show the clear button when no text exists in the source field', createTest(() => {
browserSync.get(googleTranslateUrl);
const rootElement = elementSync.findVisible('#gt-src-c');
polledExpect(() => rootElement.findElement('.clear-button').isDisplayed()).toEqual(false);
}));
it('does show the clear button after entering text in the source field', createTest(() => {
browserSync.get(googleTranslateUrl);
const rootElement = elementSync.findVisible('#gt-src-c');
rootElement.findVisible('textarea#source').clear().sendKeys('12345');
polledExpect(() => rootElement.findElement('.clear-button').isDisplayed()).toEqual(true);
}));
});
See test/spec/protractor-sync_test.ts for more examples.
Thanks you for your interest in Protractor-sync. In lieu of a formal style guide, take care to maintain the existing coding style. Please add tests for any new or changed functionality.
See API.md
browserSync.getBrowser().waitForAngularEnabled(false);
) for faster tests. You can also enable/disable it during portions of tests.findVisible
, except for special situations where you want to select a hidden element.npm start
- Builds the code and watches for changesnpm test
- Builds the code, runs the linter, updates Webdriver if needed, and runs the test suitenpm publish
- Publish a new version to NPMThis project will automatically build, lint and test when pushing code to a remote repository.