Skip to content

Commit

Permalink
Merge pull request #1704 from jdi-testing/issue_1679-fix-create-new-l…
Browse files Browse the repository at this point in the history
…ocator-bug

Issue 1679: fix bug creating new locator
  • Loading branch information
Iogsotot authored Apr 5, 2024
2 parents b2d046f + 4bda5ce commit 1d231f7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
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.20",
"version": "3.15.21",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdn-ai-chrome-extension",
"version": "3.15.20",
"version": "3.15.21",
"description": "jdn-ai chrome extension",
"scripts": {
"start": "webpack --watch --env devenv",
Expand Down
30 changes: 18 additions & 12 deletions src/features/locators/components/LocatorEditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,33 @@ export const LocatorEditDialog: React.FC<Props> = ({
// in case if user didn't touch locator field to avoid forceUpdate
const locatorMessage = isLocatorFieldTouched ? validationMessage : LocatorValidationWarnings.NotFound;

const {
name: locatorFormName,
type: locatorFormElementClass,
locator: locatorFormValue,
locatorType: locatorFormType,
annotationType: locatorFormAnnotationType,
} = await form.validateFields();
const fieldsValue = await form.validateFields();

const formData = {
name: fieldsValue.name,
elementClass: fieldsValue.type,
locatorValue: fieldsValue.locator,
locatorType: fieldsValue.locatorType,
annotationType: fieldsValue.annotationType,
};

const newLocatorData: ILocator & { locatorFormValue: string } = {
...newLocatorStub,
pageObj: pageObjectId,
isCustomName: isEditedName,
predicted_label: type.toLowerCase(),
annotationType: locatorFormAnnotationType,
locatorType: locatorFormType,
annotationType: formData.annotationType,
locatorType: formData.locatorType,
message: locatorMessage,
name: locatorFormName,
type: locatorFormElementClass,
locatorFormValue,
name: formData.name,
type: formData.elementClass,
locatorFormValue: formData.locatorValue,
};

if (formData.locatorType === LocatorType.xPath) {
newLocatorData.locatorValue.xPath = formData.locatorValue;
}

await dispatch(addCustomLocator({ newLocatorData }));
closeDialog();
};
Expand Down
4 changes: 2 additions & 2 deletions src/features/locators/reducers/addCustomLocator.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ActionReducerMapBuilder, createAsyncThunk } from '@reduxjs/toolkit';
import { ILocator, LocatorsState, ValidationStatus } from '../types/locator.types';
import { generateId, getElementFullXpath } from '../../../common/utils/helpers';
import { addLocatorToPageObj } from '../../pageObjects/pageObject.slice';
import { addLocators, setScrollToLocator, setActiveSingle } from '../locators.slice';
import { getLocatorValidationStatus, evaluateXpath, generateSelectorByHash, evaluateLocator } from '../utils/utils';
import { addLocators, setActiveSingle, setScrollToLocator } from '../locators.slice';
import { evaluateLocator, evaluateXpath, generateSelectorByHash, getLocatorValidationStatus } from '../utils/utils';
import { sendMessage } from '../../../pageServices/connector';
import { locatorsAdapter } from '../selectors/locators.selectors';
import { LocatorType } from '../../../common/types/common';
Expand Down

0 comments on commit 1d231f7

Please sign in to comment.