Skip to content

Instantly share code, notes, and snippets.

@carrodher
Created November 12, 2018 18:54
Show Gist options
  • Save carrodher/8d45b74bc34983d9055ec4566090ba0d to your computer and use it in GitHub Desktop.
Save carrodher/8d45b74bc34983d9055ec4566090ba0d to your computer and use it in GitHub Desktop.
Click on page menu test
casper.options.viewportSize = {width: 1280, height: 639};
const testingMode = process.env.TESTING_MODE;
const httpUrl = 'http://cms-' + testingMode + '-node:3000'
casper.test.begin('Click Page Menu Test', function(test) {
casper.start(httpUrl);
casper.waitForText('Welcome to my new Blog', function() {
this.test.assertTextExists('Welcome to my new Blog', '"Welcome to my new Blog" text appears');
this.capture('welcome.png');
});
casper.waitUntilVisible('a.login-link', function() {
this.test.assertVisible('a.login-link', 'Login link is visible. Clicking...');
this.capture('login.png');
this.click('a.login-link');
});
casper.waitUntilVisible('form[action="/login"]', function() {
this.test.assertVisible('form[action="/login"]', 'Form is visible. Filling...');
this.capture('formEmpty.png');
this.fillSelectors('form[action="/login"]', {
'input#username': 'admin',
'input#password': '12345',
}, false);
this.capture('formFilled.png');
this.test.assertVisible('input[value="Log In"]', 'Log In button is visible. Clicking...');
this.click('input[value="Log In"]');
});
casper.waitForText('My Blog!', function() {
this.test.assertTextExists('My Blog!', 'Logged in successfully!');
this.capture('loggedIn.png');
});
casper.waitUntilVisible('button.apos-button--global', function() {
this.test.assertVisible('button.apos-button--global', '"Page Menu" button is visible. Clicking...');
this.capture('menu.png');
this.click('button.apos-button--global');
});
casper.waitUntilVisible('li[data-apos-insert-page=""]', function() {
this.test.assertVisible('li[data-apos-insert-page=""]', '- Insert page is visible');
this.test.assertVisible('li[data-apos-copy-page=""]', '- Copy page is visible');
this.test.assertVisible('li[data-apos-update-page=""]', '- Update page is visible');
this.test.assertVisible('li[data-apos-versions-page=""]', '- Versions page is visible');
this.test.assertVisible('li[data-apos-trash-page=""]', '- Trash page is visible');
this.test.assertVisible('li[data-apos-reorganize-page=""]', '- Reorganize page is visible');
});
casper.run();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment