codeceptjs / codeceptjs/CodeceptJS

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

Aberta
#2,153 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
4.2k
Forks
757
Merge médio
2d 9h
PRs com merge (30d)
16

Descrição

#### 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
}
}
}
```

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece com src/providers_test.js e a configuração do helper do Puppeteer; em seguida, reproduza o fluxo OAuth em que a próxima aba executa window.close(). Compare o comportamento da sessão antes e depois de fechar a aba; está concluído quando a janela principal consegue continuar o teste sem um erro de protocolo “Session closed”.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript, nodejs
Domínio
testing-qa
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.