DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.81k stars 668 forks source link

Uncaught TypeError: Cannot read property 'getItem' of null #1903

Closed hang-ren closed 6 years ago

hang-ren commented 6 years ago

Are you requesting a feature or reporting a bug?

A bug

What is the current behavior?

Throw exception that block my test.

What is the expected behavior?

Run pass.

How would you reproduce the current behavior (if this is a bug)?

Just run my case. It will pass if ran it manually.

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://alpha-www.shejijia.com/ Test code

import LoginCSS from '../modules/desinerlogin';
import { Selector } from 'testcafe';

const loginCss = new LoginCSS();
const myavatar=Selector('img[id="userAvatar"]');
const mybidlist= Selector('span[class="icon-persion"]');
const mypro= Selector('i[class="Personal_bg_icon Personal_bg_icon2"]');
const beishu= Selector('a[href="#beishuOrder"]');
const to3D= Selector('a[data-original-title="进入3D设计"]');

fixture `test_To3D`
   .page `https://alpha-www.shejijia.com/`
   .beforeEach( async t => {
        await loginCss.login();
    });

test('test_To3D', async t => {
   await t
       .wait(4000)
       .hover(myavatar)
       .wait(2000)
       .click(mybidlist)
       .wait(2000)
       .click(mypro)
       .wait(4000)
       .click(beishu)
       .wait(4000)
       .click(to3D)
       .wait(4000)
});

Specify your

hang-ren commented 6 years ago

File ../modules/desinerlogin:

import { t  } from 'testcafe';

var logindata = require('../data/designerlogin.js');

export default class LoginCSS {
    constructor () {
        this.logina = logindata.logina;
        this.loginpage = logindata.loginpage;
        this.usernameInput = logindata.usernameInput;
        this.pwdInput  = logindata.pwdInput;
        this.loginBtn  = logindata.loginBtn;
        this.loginLink = logindata.loginLink;       
    }

    async login () {
        await t
        .maximizeWindow()
        .wait(5000)
        .click(this.logina)
        .wait(2000)
        .switchToIframe( this.loginpage )
        .wait(2000)
        .typeText(this.usernameInput,logindata.usname)  
        .wait(2000)
        .typeText(this.pwdInput, logindata.pwd)
        .wait(2000)
        .click(this.loginBtn)       
        .wait(2000)
        .switchToMainWindow()
        .wait(2000)
    }
}
hang-ren commented 6 years ago

File ../data/desinerlogin:

import { Selector } from 'testcafe';

var usname = "13621084964";
var pwd = "123456";
var logina = Selector('li[id="no-login"]');
var loginpage = Selector('iframe[id="login-iframe"]');
var usernameInput = Selector('input[placeholder="手机/邮箱/用户名"]');
var pwdInput = Selector('input[placeholder="密码"]');
var loginBtn = Selector('a[class="sso-submit"]');

exports.usname = usname;
exports.pwd = pwd;
exports.logina = logina;
exports.loginpage = loginpage;
exports.usernameInput = usernameInput;
exports.pwdInput = pwdInput;
exports.loginBtn = loginBtn;
helen-dikareva commented 6 years ago

@hang-ren, thank you for your report. We are aware about this problem - it occurs when the colsole.log method is called in the iframe before we initialize some of our stuff (you can see more information in this issue). We will fix it ASAP.

hang-ren commented 6 years ago

@helen-dikareva, thanks Helen!

lock[bot] commented 5 years ago

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.