Skip to content

Commit

Permalink
Merge pull request #1767 from jdi-testing/issue_1598-pass-screen-reso…
Browse files Browse the repository at this point in the history
…lution-to-predict-endpoints

Issue 1598: pass screen resolution to predict endpoints
  • Loading branch information
Iogsotot authored Aug 15, 2024
2 parents 632408b + 388e065 commit 29156b9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 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.16.4",
"version": "3.16.5",
"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.16.4",
"version": "3.16.5",
"description": "jdn-ai chrome extension",
"scripts": {
"start": "webpack --watch --env devenv",
Expand Down
10 changes: 10 additions & 0 deletions src/common/utils/getViewportResolution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import connector from '../../pageServices/connector';

export const getViewportResolution = async () => {
return await connector.attachContentScript(() => {
const width = window.innerWidth;
const height = window.innerHeight;

return { width, height };
});
};
10 changes: 7 additions & 3 deletions src/pageServices/pageDataHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getFullDocumentWithStyles } from '../common/utils/getFullDocumentWithSt
import { ILocator, PredictedEntity } from '../features/locators/types/locator.types';
import { getLibrarySelectors } from '../services/rules/createSelector';
import { VueRules } from '../services/rules/Vue.rules';
import { getViewportResolution } from '../common/utils/getViewportResolution';
// /* global chrome */

let overlayID: string;
Expand Down Expand Up @@ -59,10 +60,13 @@ Function returns predicted elements. */
export const predictElements = (endpoint: HttpEndpoint): PredictElementsType => {
let pageData: string;

return Promise.all([sendMessage.getPageData(), getFullDocumentWithStyles()])
.then(([pageDataResult, documentResult]) => {
return Promise.all([sendMessage.getPageData(), getFullDocumentWithStyles(), getViewportResolution()])
.then(([pageDataResult, documentResult, viewportResolution]) => {
pageData = pageDataResult[0];
const payload = { elements: pageData, document: documentResult };

const viewport = JSON.stringify(viewportResolution[0].result);
const payload = { elements: pageData, document: documentResult, viewport };

return sendToModel(payload, endpoint);
})
.then(
Expand Down

0 comments on commit 29156b9

Please sign in to comment.