Merge pull request #393 from RohitR311/inputd-fix
feat: order the input field logic to fix inputs
This commit is contained in:
@@ -354,40 +354,6 @@ export class WorkflowGenerator {
|
||||
const elementInfo = await getElementInformation(page, coordinates, '', false);
|
||||
console.log("Element info: ", elementInfo);
|
||||
|
||||
if ((elementInfo?.tagName === 'INPUT' || elementInfo?.tagName === 'TEXTAREA') && selector) {
|
||||
// Calculate the exact position within the element
|
||||
const elementPos = await page.evaluate((selector) => {
|
||||
const element = document.querySelector(selector);
|
||||
if (!element) return null;
|
||||
const rect = element.getBoundingClientRect();
|
||||
return {
|
||||
x: rect.left,
|
||||
y: rect.top
|
||||
};
|
||||
}, selector);
|
||||
|
||||
if (elementPos) {
|
||||
const relativeX = coordinates.x - elementPos.x;
|
||||
const relativeY = coordinates.y - elementPos.y;
|
||||
|
||||
const pair: WhereWhatPair = {
|
||||
where,
|
||||
what: [{
|
||||
action: 'click',
|
||||
args: [selector, { position: { x: relativeX, y: relativeY } }]
|
||||
}]
|
||||
};
|
||||
|
||||
if (selector) {
|
||||
this.generatedData.lastUsedSelector = selector;
|
||||
this.generatedData.lastAction = 'click';
|
||||
}
|
||||
|
||||
await this.addPairToWorkflowAndNotifyClient(pair, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if clicked element is a select dropdown
|
||||
const isDropdown = elementInfo?.tagName === 'SELECT';
|
||||
|
||||
@@ -459,6 +425,40 @@ export class WorkflowGenerator {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((elementInfo?.tagName === 'INPUT' || elementInfo?.tagName === 'TEXTAREA') && selector) {
|
||||
// Calculate the exact position within the element
|
||||
const elementPos = await page.evaluate((selector) => {
|
||||
const element = document.querySelector(selector);
|
||||
if (!element) return null;
|
||||
const rect = element.getBoundingClientRect();
|
||||
return {
|
||||
x: rect.left,
|
||||
y: rect.top
|
||||
};
|
||||
}, selector);
|
||||
|
||||
if (elementPos) {
|
||||
const relativeX = coordinates.x - elementPos.x;
|
||||
const relativeY = coordinates.y - elementPos.y;
|
||||
|
||||
const pair: WhereWhatPair = {
|
||||
where,
|
||||
what: [{
|
||||
action: 'click',
|
||||
args: [selector, { position: { x: relativeX, y: relativeY } }]
|
||||
}]
|
||||
};
|
||||
|
||||
if (selector) {
|
||||
this.generatedData.lastUsedSelector = selector;
|
||||
this.generatedData.lastAction = 'click';
|
||||
}
|
||||
|
||||
await this.addPairToWorkflowAndNotifyClient(pair, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//const element = await getElementMouseIsOver(page, coordinates);
|
||||
//logger.log('debug', `Element: ${JSON.stringify(element, null, 2)}`);
|
||||
if (selector) {
|
||||
|
||||
Reference in New Issue
Block a user