MOBILE-4470 behat: Fix header step

main
Noel De Martin 2024-05-13 13:15:30 +02:00
parent bb4736a5b7
commit f6b5cd9d79
1 changed files with 7 additions and 7 deletions

View File

@ -509,16 +509,16 @@ export class TestingBehatRuntimeService {
getHeader(): string {
this.log('Action - Get header');
let titles = Array.from(document.querySelectorAll<HTMLElement>('.ion-page:not(.ion-page-hidden) > ion-header h1'))
const getBySelector = (selector: string ) => Array.from(document.querySelectorAll<HTMLElement>(selector))
.filter((title) => TestingBehatDomUtils.isElementVisible(title, document.body))
.map((title) => title.innerText.trim());
.map((title) => title.innerText.trim())
.filter((title) => title.length > 0);
let titles = getBySelector('.ion-page:not(.ion-page-hidden) > ion-header h1');
// Collapsed title, get the floating title.
if (titles.length < 0 || (titles.length === 1 && titles[0] === '')) {
titles = Array.from(document.querySelectorAll<HTMLElement>(
'.ion-page:not(.ion-page-hidden) h1.collapsible-header-floating-title',
)).filter((title) => TestingBehatDomUtils.isElementVisible(title, document.body))
.map((title) => title.innerText.trim());
if (titles.length === 0) {
titles = getBySelector('.ion-page:not(.ion-page-hidden) h1.collapsible-header-floating-title');
}
if (titles.length > 1) {