Skip to content

Commit

Permalink
Merge pull request #1731 from jdi-testing/issue_1588-escaping-special…
Browse files Browse the repository at this point in the history
…-text-locator-characters

Issue 1588: escaping special text locator characters (addional fix)
  • Loading branch information
KateDronova committed May 7, 2024
2 parents 6f3d8ad + e858a5c commit 214d77a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Expand Up @@ -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.29",
"version": "3.15.30",
"icons": {
"128": "icon128.png"
},
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jdn-ai-chrome-extension",
"version": "3.15.29",
"version": "3.15.30",
"description": "jdn-ai chrome extension",
"scripts": {
"start": "webpack --watch --env devenv",
Expand Down
1 change: 1 addition & 0 deletions src/features/locators/utils/escapeLocatorString.ts
Expand Up @@ -7,6 +7,7 @@ export const fullEscapeLocatorString = (str: string = ''): string => {
.replaceAll(/\\/g, '\\\\') // escape backslash
.replaceAll(/\"/g, '\\"') // escape double quotes
.replaceAll(/\'/g, "\\'") // escape single quotes
.replaceAll(/\b/g, '\\b') // escape backspaces
.replaceAll(/\t/g, '\\t') // escape tabs
.replaceAll(/\n/g, '\\n') // escape newlines
.replaceAll(/\r/g, '\\r') // escape carriage returns
Expand Down
4 changes: 2 additions & 2 deletions src/features/pageObjects/utils/pageObjectTemplate.ts
Expand Up @@ -49,13 +49,13 @@ export const getPageObjectTemplateForJdi = (
const { name: className, library } = pageObject;

const locatorsCode = locators.map((locator) => {
const locatorEscaped = locator.locatorValue.output?.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
const locatorOutput = locator.locatorValue.output;
const { locatorType } = pageObject;
const currentLocatorType = locator.locatorType || locatorType || LocatorType.xPath;
return ` ${locator.annotationType}(${getLocatorPrefix(
locator.annotationType,
currentLocatorType,
)}"${locatorEscaped}")\n public ${locator.type} ${locator.name};`;
)}"${locatorOutput}")\n public ${locator.type} ${locator.name};`;
});

const hasFindByAnnotationType: boolean = hasAnnotationType(locators, AnnotationType.FindBy);
Expand Down

0 comments on commit 214d77a

Please sign in to comment.