我正在使用量角器进行角度自动化测试。 如果要使用异步等待,则必须禁用控制流。因此,在我的protractor.conf.js中,我设置了SELENIUM_PROMISE_MANAGER:false。 不是被认可还是我忘记了什么?
describe('As registarar, I can open a new client in 1G1P', function(){
private const SSIN_UNDER_TEST = "03091011333";
beforeEach(async function(){
browser.waitForAngularEnabled(false);
const loginPage = new KeyCloak();
await browser.get('http://localhost:4200/1G1P/home');
await browser.sleep(1000);
await loginPage.clickLoginButton('AlisonColquhoun');
});
it('does not exist in eyouth', async() => {
const homePage = new HomePage();
browser.waitForAngularEnabled(true);
await browser.sleep(2000);
await homePage.openKszAccordion();
await homePage.ssinSearchUser(SSIN_UNDER_TEST);
const element = await homePage.firstKszSearchResult;
const isPresent = await element.isDisplayed();
expect(isPresent).toBeTruthy();
await homePage.selectFirstSearchResult();
});
});
这是我的测试。
和页面对象。我对打字稿中的页面对象模型的概念还很陌生。仅用于与页面的交互,没有断言。我应该兑现承诺吗?
export class HomePage {
private _firstNameResult: ElementFinder = $('tbody tr:nth-child(1) td:nth-child(1)');
private _lastNameResult: ElementFinder = $('tbody tr:nth-child(1) td:nth-child(2)');
private _ksz_accordion = $('#' + Element.ACCORDION_KSZ_SEARCH_FORM);
private _firstKszSearchResult = $(TAG.KSZ_SEARCH_TABLE + ' button');
private searchButton = $('#' + Element.KSZ_SEARCH_BUTTON);
private _firstNameInput = $('#' + Element.FIRSTNAME_SEARCH_INPUT);
private _lastNameInput = $('#' + Element.LASTNAME_SEARCH_INPUT);
private _birthDateInput = $('#' + Element.BIRTH_DATE_SEARCH_INPUT);
private _ssinInput = $('#' + Element.SSIN_SEARCH_INPUT);
get firstKszSearchResult(): WebElementPromise {
return this._firstKszSearchResult.getWebElement();
}
public async phoneticSearchUser(firstName: string, lastName: string, birthDate: string){
await this._firstNameInput.sendKeys(firstName);
await this._lastNameInput.sendKeys(lastName);
await this._birthDateInput.sendKeys(birthDate);
this.searchButton.click();
}
public openKszAccordion(){
return this._ksz_accordion.click();
}
public async ssinSearchUser(ssin: string){
await this._ssinInput.sendKeys(ssin);
this.searchButton.click();
}
public selectFirstSearchResult(){
this._firstKszSearchResult.click();
}
}
我的量角器配置,版本5.3.0
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
SELENIUM_PROMISE_MANAGER: false,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
browser.driver.manage().window().maximize();
},
suites: { //run with e.g. --suite=carerequest or --suite=carerequest,home
carerequest: './src/tests/carerequest/*.ts',
home: './src/tests/home/*.ts',
login: './src/tests/login/*.ts'
}
};