codeceptjs / codeceptjs/CodeceptJS

Session is destroyed when opening a new tab that executes window.close() inside that said tab

Đang mở
#2,153 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
4.2k
Fork
757
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
16

Mô tả

#### What are you trying to achieve?
Open a tab that manages oauth login and continue running test after closing the oauth window.
#### What do you get instead?
After i successfully get credentials, i call a function in window.opener that passes the info i need then calls window.close() so user is taken back to the main window where the application is running. When trying to create a test case for this, getting an error saying session is gone because window was closed.
> Provide console output if related. Use `--verbose` mode for more details.

```bash
# paste output here
- FAILURES:

1) Providers Login
Twitter login should work:
Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
```

> Provide test source code if related

```js
// paste test
Feature('Providers Login')

Scenario('Twitter login should work', (I) => {
I.amOnPage('/')
I.click('.mno-btn-red')
I.click('.twitter')
I.switchToNextTab()
I.fillField('session[username_or_email]', '@twitter username')
I.fillField('session[password]', '@twitter password')
I.click('Authorize app')
I.seeInCurrentUrl('matcherino.com')
pause()
})
```

where @twitter username should be your own account
where @twitter password should be password of your account

### Details

* CodeceptJS version: 2.4.1
* NodeJS Version: 12.4.1
* Operating System:
* puppeteer || webdriverio || protractor || testcafe version (if related) Puppeteer: 2.0.0
* Configuration file:

```js
# paste config here
const { setHeadlessWhen } = require('@codeceptjs/configure');

// turn on headless mode when running with HEADLESS=true environment variable
// HEADLESS=true npx codecept run
setHeadlessWhen(process.env.HEADLESS);

exports.config = {
// tests: './src/*_test.js',
tests: './src/providers_test.js',
output: './output',
helpers: {
Puppeteer: {
url: 'http://matcherino.com',
show: true,
waitForNavigation: ["domcontentloaded", "networkidle0"],
waitForAction: 500
}
},
include: {
I: './steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'bdd-test',
plugins: {
retryFailedStep: {
enabled: true
},
screenshotOnFail: {
enabled: true
}
}
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.