MOBILE-4031 behat: Fix search text with double quotes

main
Dani Palou 2022-05-30 11:29:04 +02:00
parent 2a87212e98
commit ee64090001
1 changed files with 4 additions and 1 deletions

View File

@ -89,7 +89,10 @@ export class TestingBehatDomUtilsService {
text: string,
options: TestingBehatFindOptions,
): ElementsWithExact[] {
const attributesSelector = `[aria-label*="${text}"], a[title*="${text}"], img[alt*="${text}"], [placeholder*="${text}"]`;
// Escape double quotes to prevent breaking the query selector.
const escapedText = text.replace(/"/g, '\\"');
const attributesSelector = `[aria-label*="${escapedText}"], a[title*="${escapedText}"], ` +
`img[alt*="${escapedText}"], [placeholder*="${escapedText}"]`;
const elements = Array.from(container.querySelectorAll<HTMLElement>(attributesSelector))
.filter((element => this.isElementVisible(element, container)))