Все ссылки, название проекта и название компании были изменены и не являются оригинальными.
У нас есть всплывающее окно базовой HTTP-аутентификации, которое появляется, когда мы получаем доступ к тестовой / промежуточной среде.
Мне интересно, как я могу ввести информацию для входа во всплывающее окно входа в систему или заранее отправить запрос api, чтобы сохранить файл cookie?
Потому что в противном случае я не смогу запустить автоматизацию в нашей тестовой среде. При тестовом доступе к странице я вижу белый веб-сайт, на котором маленькими буквами отображается слово "неавторизовано".
Вот как выглядит приглашение входа в систему при доступе к среде Test / Staging.
Мы используем следующий плагин: https://www.npmjs.com/package/gherkin-testcafe < / а>
То, что я спрашиваю, очень похоже на этот вопрос: https://stackoverflow.com/questions/10735923/testing-http-basic-authentication-with-cucumber-and-rspec-in-rails-3-2-3
Я попытался добавить роль и использовать TestCafe http-authentication.html
Вот что я тестировал на данный момент:
TestCafe пытается использовать роль:
const { Role } = require('testcafe');
const regularAccUser = Role('https://website/login', async t => {
await t
.typeText('#login', 'username')
.typeText('#password', 'password')
.click('#sign-in');
});
Given("I am open Dealer's login page", async t => {
await t
.useRole(regularAccUser)
.navigateTo(`${url}/login`);
});
Это дает мне:
ERROR CompositeParserException: Parser errors:
(7:3): expected: #EOF, #Comment, #BackgroundLine, #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Empty, got 'Correct action happens when user provide either wrong or correct login information'
at Function.Errors.CompositeParserException.create (/Users/dennis/Projects/src/company/project/node_modules/gherkin/lib/gherkin/errors.js:27:13)
at Parser.parse (/Users/dennis/Projects/src/company/project/node_modules/gherkin/lib/gherkin/parser.js:72:45)
at specFiles.forEach.specFile (/Users/dennis/Projects/src/company/project/node_modules/gherkin-testcafe/src/compiler.js:43:33)
at Array.forEach (<anonymous>)
at GherkinTestcafeCompiler.getTests (/Users/dennis/Projects/src/company/project/node_modules/gherkin-testcafe/src/compiler.js:42:20)
at getTests (/Users/dennis/Projects/src/company/project/node_modules/testcafe/src/runner/bootstrapper.js:79:47)
at Generator.next (<anonymous>)
at step (/Users/dennis/Projects/src/company/project/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /Users/dennis/Projects/src/company/project/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
Если я попробую использовать:
import {Role} from 'testcafe'
Я получил:
tests/ui/stepDefinitions/login/login.js:1
(function (exports, require, module, __filename, __dirname) { import { Role } from 'testcafe';
^
SyntaxError: Unexpected token {
Использование HTTP-аутентификации TestCafe:
Feature: Login with correct and wrong info functionallity
.page('website/login')
.httpAuth({
username: 'username',
password: 'password',
})
Correct action happens when user provide either wrong or correct login information
@loginFunc
Scenario: Should NOT be able to login without filling in any credentials
Given I am open Dealer's login page
When I am login in with "empty" and "empty"
Then I should NOT be able to press the login button
Я получаю следующее:
Feature: Login with correct and wrong info functionallity
✖ Scenario: Should NOT be able to login without filling in any credentials
1) Cannot obtain information about the node because the specified selector does not match any node in the DOM tree.
| Selector('button[data-qa="qa-login-submit-button"]')
> | Selector('button[data-qa="qa-login-submit-button"]')
Browser: Chrome 72.0.3626 / Mac OS X 10.14.3
32 | }
33 |});
34 |
35 |Then("I should NOT be able to press the login button", async t => {
36 | await t
> 37 | .expect(submitButton.hasAttribute('disabled')).ok()
38 | .expect(h1.exists).eql(true);
39 |});
```
It is basically showing me a white screen and saying: "**unauthorized**" in small letters.