diff --git a/manifest.json b/manifest.json index 7f6ee507..30435875 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "JDN — Page Object Generator", "description": "JDN – helps Test Automation Engineer to create Page Objects in the test automation framework and speed up test development", "devtools_page": "index.html", - "version": "3.15.27", + "version": "3.15.28", "icons": { "128": "icon128.png" }, diff --git a/package-lock.json b/package-lock.json index 2704ca4e..2b57888b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.15.27", + "version": "3.15.28", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 7d695e6b..582605e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.15.27", + "version": "3.15.28", "description": "jdn-ai chrome extension", "scripts": { "start": "webpack --watch --env devenv", diff --git a/src/features/locators/components/LocatorsTree.tsx b/src/features/locators/components/LocatorsTree.tsx index 136b2e1d..6edc2576 100644 --- a/src/features/locators/components/LocatorsTree.tsx +++ b/src/features/locators/components/LocatorsTree.tsx @@ -16,6 +16,8 @@ import { selectCurrentPageObject } from '../../pageObjects/selectors/pageObjects import { selectPresentLocatorsByPO } from '../selectors/locatorsByPO.selectors'; import { selectFilteredLocators } from '../selectors/locatorsFiltered.selectors'; import { isLocatorListPage } from '../../../app/utils/helpers'; +import { fullEscapeLocatorString, checkForEscaped } from '../utils/escapeLocatorString'; +import { LocatorType } from '../../../common/types/common'; import type RcTree from 'rc-tree'; import cn from 'classnames'; @@ -118,6 +120,10 @@ export const LocatorsTree: React.FC = ({ locatorIds, viewProps const { element_id, children, parent_id, jdnHash, searchState, depth } = element; const locator = locatorsMap[element_id]; + if (locator.locatorType === LocatorType.linkText && !checkForEscaped(locator.locatorValue.output)) { + locator.locatorValue.output = fullEscapeLocatorString(locator.locatorValue.output); + } + const className = cn({ 'jdn__tree-item--selected': locator?.isGenerated && isLocatorListPage(currentPage), 'jdn__tree-item--active': locator?.active, diff --git a/src/features/locators/utils/escapeLocatorString.ts b/src/features/locators/utils/escapeLocatorString.ts index 69a6957d..5fe3356f 100644 --- a/src/features/locators/utils/escapeLocatorString.ts +++ b/src/features/locators/utils/escapeLocatorString.ts @@ -1,3 +1,19 @@ export const escapeLocatorString = (selector: string): string => { return selector.replace(/(["'\\])/g, '\\$1'); }; + +export const fullEscapeLocatorString = (str: string = ''): string => { + return str + .replaceAll(/\\/g, '\\\\') // escape backslash + .replaceAll(/\"/g, '\\"') // escape double quotes + .replaceAll(/\'/g, "\\'") // escape single quotes + .replaceAll(/\t/g, '\\t') // escape tabs + .replaceAll(/\n/g, '\\n') // escape newlines + .replaceAll(/\r/g, '\\r') // escape carriage returns + .replaceAll(/\f/g, '\\f'); // escape form feeds +}; + +export const checkForEscaped = (str: string = ''): boolean => { + const found = str.match(/\\/); + return found ? true : false; +};