Open mgtalasila opened 7 years ago
That looks valid. Is that an onBeforeScript? Does your login work if you just create it outside of backstop using casper scripts?
Also, you could probably replace this
with casper
.
I am not too familiar with casper and didn't try that outside backstop
I changed this with casper, still no luck, test reports pass but not logged in.
Other thing I observed is onbefore.js is not being called or executed at all, am I missing anything basic?
If it's not running at all there could be something wrong with your syntax. If it is mainly acquiring credentials you may be better off simply setting cookies. Here is an example script you could try for that. https://github.com/garris/BackstopJS/tree/master/examples/set%20cookies%20onBefore
Thanks Garris,
I managed to get my login called but seeing 'CasperJS: [warning] [remote] unable to submit form' warning, though it is not throwing any error, it is not capturing the screenshots, have you come across any such issue?
below is my log..
CasperJS: [debug] [phantom] Successfully injected Casper client-side utilities CasperJS: [info] [phantom] Step anonymous 2/3 https://XXXXXXX (HTTP 200) CasperJS: [info] [phantom] Step anonymous 2/3: done in 4286ms. CasperJS: [info] [phantom] Step _step 3/4 https://XXXXXXX (HTTP 200) CasperJS: [info] [phantom] Step _step 3/4: done in 4307ms. CasperJS: [info] [phantom] waitFor() finished in 40ms. CasperJS: [info] [phantom] Step anonymous 4/5 https://XXXXXXX (HTTP 200) CasperJS: .....Trying to login...... CasperJS: [info] [remote] attempting to fetch form element from selector: '#ius-form-sign-in' CasperJS: [debug] [remote] Set "Email" field value to XXXXX@gmail.com CasperJS: [debug] [remote] Set "Password" field value to **** CasperJS: [info] [remote] submitting form to #, HTTP POST CasperJS: [warning] [remote] unable to submit form
@mgtalasila I don't see click/submit action in your first casper script. Do you have it else where?, can you try clicking submit button with a script?
@kiran-redhat I did not have explicit considering the fill/fillselectors takes care of submitting form base don casperjs documentation
here is my latest login script..
module.exports = function (casper, scenario, vp) { // This script runs before your app loads. Edit here to log-in, load cookies or set other states required for your test. console.log('onBefore.js has run for ' + vp.name + '.'); casper.options.waitTimeout = 20000; casper.start(scenario.url, function() { casper.waitForSelector('#ius-form-sign-in', function() { console.log('.....Trying to login......'); this.fillSelectors('#ius-form-sign-in', { 'input[id = ius-userid]' : 'XXXXXXX', 'input[id = ius-password]' : 'XXXXXXX' }, true); casper.open(scenario.urlCheckout); }); }); };
Go you still see the issue? If so this:
casper.waitUntilVisible('#ius-form-sign-in', function (){ // Here fill user name, password and click on //Submit. Then wait for some locator displayed //once logged in })
thanks Kiran, Login is working with the above approach rather than optional submit comes with fillSelectors.
here comes the new issue.. After Login, I don't have anything in onBefore.js and onReady.js , it should start capturing screenshots.. but ending there without doing so.
Updated Login Script:
module.exports = function (casper, scenario, vp) { console.log('onBefore.js has run for ' + vp.name + '.'); casper.options.waitTimeout = 40000; casper.start(scenario.url, function() { casper.waitUntilVisible('#ius-form-sign-in', function (){ console.log('.....Trying to login......'); this.fillSelectors('#ius-form-sign-in', { 'input[id = ius-userid]' : 'XXXXX@gmail.com', 'input[id = ius-password]' : 'XXXXX' }); this.click('#ius-sign-in-submit-btn-text'); }); casper.waitUntilVisible('#ius-user-id-manager-content-label', function() { console.log('.....logged in......'); console.log('current url....' + this.getCurrentUrl()); }); }); };
debug log:
CasperJS: [info] [phantom] waitFor() finished in 3942ms. CasperJS: [info] [phantom] Step anonymous 6/7 https://accounts-e2e.intuit.com/account-manager.html (HTTP 200) CasperJS: .....logged in...... CasperJS: current url....https://accounts-e2e.XXXXX.com/account-manager.html CasperJS: [info] [phantom] Step anonymous 6/7: done in 5089ms. CasperJS: [info] [phantom] Step _step 7/7 https://accounts-e2e.XXXXX.com/account-manager.html (HTTP 200) CasperJS: [info] [phantom] Step _step 7/7: done in 5109ms. CasperJS: linked-identities-manager-lookup-success CasperJS: [info] [phantom] Done 7 steps in 5213ms CasperJS: Comparison config file updated. CasperJS: [debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true CasperJS: [debug] [phantom] url changed to "about:blank"
Bitmap file generation completed.
@mgtalasila , try adding onReady script and put a step to wait for one of the selector on page(once you successfully logged in. default it should take document screenshot if you don't specify any locators.
casper.waitUntilVisibile("selector", function() { });
i've the same issue, this is the script i put on OnBefore.js but didn't work for me:
module.exports = function (casper, scenario, vp) { console.log('onBefore.js has run for ' + vp.name + '.'); casper.then(function() { casper.waitUntilVisible('#frm_login', function () { casper.fillSelectors('#frm_login', { '#Email': 'xxxxxxxxx', '#Password': 'xxxxxxxx' }); casper.click('#js-lite-login-submit'); }); }) casper.thenOpen(scenario.url); }
anyone can help me?
I have pages which required login to validate and I am using below login script in onbefore.js but it is not working. Please let me know if I am using the right login script, I am not seeing any errors in log either.
// EXAMPLE: LOGIN BEFORE RUNNING TESTS module.exports = function(casper, scenario, vp) { casper.thenOpen(scenario.url, function(){ if (this.exists('form#user-login-form')) { this.fill('form#loginForm',{ 'username': 'XXXXXX', 'password': 'XXXXXX' }, true); } }); };