feat: chain and store selectors in pagination mode
This commit is contained in:
@@ -64,6 +64,8 @@ export class WorkflowGenerator {
|
|||||||
|
|
||||||
private listSelector: string = '';
|
private listSelector: string = '';
|
||||||
|
|
||||||
|
private paginationMode: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The public constructor of the WorkflowGenerator.
|
* The public constructor of the WorkflowGenerator.
|
||||||
* Takes socket for communication as a parameter and registers some important events on it.
|
* Takes socket for communication as a parameter and registers some important events on it.
|
||||||
@@ -120,6 +122,9 @@ export class WorkflowGenerator {
|
|||||||
this.socket.on('listSelector', (data: { selector: string }) => {
|
this.socket.on('listSelector', (data: { selector: string }) => {
|
||||||
this.listSelector = data.selector;
|
this.listSelector = data.selector;
|
||||||
})
|
})
|
||||||
|
this.socket.on('setPaginationMode', (data: { pagination: boolean }) => {
|
||||||
|
this.paginationMode = data.pagination;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -703,6 +708,24 @@ export class WorkflowGenerator {
|
|||||||
? await getNonUniqueSelectors(page, coordinates, this.listSelector)
|
? await getNonUniqueSelectors(page, coordinates, this.listSelector)
|
||||||
: await getSelectors(page, coordinates);
|
: await getSelectors(page, coordinates);
|
||||||
|
|
||||||
|
if (this.paginationMode && selectorBasedOnCustomAction) {
|
||||||
|
// Chain selectors in specific priority order
|
||||||
|
const selectors = selectorBasedOnCustomAction;
|
||||||
|
const selectorChain = [
|
||||||
|
selectors?.testIdSelector,
|
||||||
|
selectors?.id,
|
||||||
|
selectors?.hrefSelector,
|
||||||
|
selectors?.accessibilitySelector,
|
||||||
|
selectors?.attrSelector,
|
||||||
|
selectors?.generalSelector
|
||||||
|
]
|
||||||
|
.filter(selector => selector !== null && selector !== undefined)
|
||||||
|
.join(',');
|
||||||
|
|
||||||
|
console.log("CHAINED PAGINATION SELECTOR:", selectorChain);
|
||||||
|
return selectorChain;
|
||||||
|
}
|
||||||
|
|
||||||
const bestSelector = getBestSelectorForAction(
|
const bestSelector = getBestSelectorForAction(
|
||||||
{
|
{
|
||||||
type: action,
|
type: action,
|
||||||
|
|||||||
Reference in New Issue
Block a user