Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't login with Testcafe #2166

Closed
rahulrana1 opened this issue Oct 24, 2019 · 13 comments
Closed

Can't login with Testcafe #2166

rahulrana1 opened this issue Oct 24, 2019 · 13 comments
Labels
Milestone

Comments

@rahulrana1
Copy link

What is your Test Scenario?

Login to the application

What is the Current behavior?

Test cafe cannot login to the app

What is the Expected behavior?

Login works fine outside testcafe.

What is your web application and your TestCafe test code?

Given you the access via support email

Steps to Reproduce:

  1. Go to my website
  2. Click on the sign in
  3. Provide credentials and click sign in
  4. Check the error on top(cannot login this time). This happens only when running tests via testcafe.

Your Environment details:

  • testcafe version: 1.5.0
  • node.js version: 10.16.0
  • browser name and version: chrome 77
  • platform and version: macOS

Your website URL (or attach your complete example):

Your complete test code (or attach your test files):
 export const roleCFC =  Role('XXXXX', async t => { 
    await t
        .click(Selector('.button.signIn'))
        .typeText(Selector('input').withAttribute('name','email'),'XXXX')
        .typeText(Selector('input').withAttribute('name','password'),'XXXX')
        .click(Selector('span.auth0-label-submit'))
}, { preserveUrl: true });
import { Selector, RequestLogger } from 'testcafe';
import {roleCFC} from '../../roles/roles'

fixture `CFC TestCafe POC`

    test('Login to app', async t => {
        await t
          await t.useRole(roleCFC)
          await t.debug()
          await t.wait(10000)
    });
const createTestCafe = require('testcafe');
let testcafe = null;
let runner = null;
const reporters = [
    {
        "name" :'spec'
    },
    /*{ 
       "name": 'slack', 
       "output": "reports/slack.json" 
    }*/
]

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe = tc;
        runner   = testcafe.createRunner();

        return runner           
	   .src('./tests/cfc/cfc.js')
            .browsers(['chrome'])
            .reporter(reporters)
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    })
@miherlosev miherlosev self-assigned this Oct 24, 2019
@miherlosev
Copy link
Contributor

Hi @rahulrana1

Could you please provide a public URL or example application with which I can run the provided test code?

@miherlosev
Copy link
Contributor

Thank you for the provided information. I've reproduced the problem.

@miherlosev miherlosev transferred this issue from DevExpress/testcafe Oct 24, 2019
@LavrovArtem LavrovArtem added this to the Sprint #46 milestone Nov 20, 2019
@LavrovArtem LavrovArtem modified the milestones: Sprint #46, Planned Dec 9, 2019
@rahulrana1
Copy link
Author

Hi @miherlosev @LavrovArtem , Do you have any updates on this issue?

@AlexSkorkin
Copy link
Contributor

We are still looking into this issue. You will be automatically notified once we make progress.

@LavrovArtem LavrovArtem added this to Need research in Categorization Feb 13, 2020
@LavrovArtem LavrovArtem removed this from the Planned milestone Feb 26, 2020
@LavrovArtem
Copy link
Contributor

Hello @rahulrana1,

Data privacy is our top priority. For safety reasons, we did not save your data after our last attempt to find the cause of the issue. Could you please resend it?

@rahulrana1
Copy link
Author

@LavrovArtem I have share the test data again with support@devexpress.com.
Could you possibly get in touch with them?

@miherlosev
Copy link
Contributor

Hi @rahulrana1

We received the data you sent. @LavrovArtem is investigating the issue right now.

@LavrovArtem
Copy link
Contributor

For team!

A simplified example server:

require('http')
    .createServer((req, res) => {
        if (req.url === '/') {
            if (req.headers.host !== 'site.test.com:2020')
                return res.end('Wrong request!');

            res.writeHead(200, { 'content-type': 'text/html' });
            res.end(`
                <div id="cookie"></div>
                <div><button id="signup">Sign up</button></div>
                <script>
                    var cookieDiv = document.querySelector('#cookie');
                    var signupButton = document.querySelector('#signup');

                    document.cookie = 'session_id=1234567890; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT';

                    setInterval(function () {
                        cookieDiv.textContent = document.cookie;
                    }, 100);
                    
                    signupButton.addEventListener('click', function () {
                        var iframe = document.createElement('iframe');

                        iframe.setAttribute('src', 'http://site.test.com:2020/signup');
                        document.body.appendChild(iframe);
                    });
                </script>
            `);
        }
        else if (req.url === '/signup') {
            if (req.headers.host !== 'site.test.com:2020')
                return res.end('Wrong request!');

            res.writeHead(302, {
                'set-cookie': 'session_id=1234567890; path=/',
                'location': 'http://auth.test.com:2020/auth'
            });
            res.end();
        }
        else if (req.url === '/auth') {
            if (req.headers.host !== 'auth.test.com:2020')
                return res.end('Wrong request!');

            res.writeHead(200, { 'content-type': 'text/html' });
            res.end(`
                <button id="auth">Auth</button>
                <script>
                    document.querySelector('#auth').addEventListener('click', function () {
                        var xhr = new XMLHttpRequest();

                        xhr.addEventListener('load', function () {
                            window.location = 'http://site.test.com:2020/finish';
                        });
                        xhr.open('post', 'http://site.test.com:2020/xhr');
                        xhr.send();
                    });
                </script>
            `);
        }
        else if (req.url === '/xhr') {
            if (req.headers.host !== 'site.test.com:2020')
                return res.end('Wrong request!');

            res.writeHead(200, {
                'content-type': 'text/plain',
                'set-cookie': 'session_id=0987654321; path=/',
                'access-control-allow-origin': 'http://auth.test.com:2020'
            });
            res.end('ok!');
        }
        else if (req.url === '/finish') {
            if (req.headers.host !== 'site.test.com:2020')
                return res.end('Wrong request!');

            res.writeHead(200, { 'content-type': 'text/html' });
            res.end(`
                <script>
                    parent.document.querySelector("#signup").parentNode.textContent = "${ req.headers.cookie !== 'session_id=1234567890' ? 'Failed!' : 'Success!' }";
                    parent.document.body.removeChild(frameElement);
                </script>
            `);
        }
        else
            res.end();
    })
    .listen(2020, () => console.log('Open http://site.test.com:2020/'));

Need to add two lines in the hosts file for working of this example:

127.0.0.1 site.test.com
127.0.0.1 auth.test.com

@LavrovArtem LavrovArtem removed this from Need research in Categorization Apr 14, 2020
@LavrovArtem LavrovArtem added this to the Sprint #55 milestone Apr 21, 2020
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Apr 27, 2020
@AndreyBelym AndreyBelym modified the milestones: Sprint #55, Sprint #56 Apr 28, 2020
@rahulrana1
Copy link
Author

@miherlosev @AndreyBelym Has this fix been released?

@AlexanderMoiseev
Copy link

Hi @rahulrana1

The fix will be available in the next public Testcafe release.

@rahulrana1
Copy link
Author

rahulrana1 commented May 1, 2020

awesome, thanks @AlexanderMoiseev
Is it possible to share a target date for the release?

@AlexSkorkin
Copy link
Contributor

We didn't establish the target date yet. And any personal estimate may be misleading, so I cannot currently tell you the precise date.

@lock
Copy link

lock bot commented May 20, 2020

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked Issues that were automatically locked by the Lock bot label May 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants