feat: chain and store selectors in pagination mode
This commit is contained in:
@@ -64,6 +64,8 @@ export class WorkflowGenerator {
|
||||
|
||||
private listSelector: string = '';
|
||||
|
||||
private paginationMode: boolean = false;
|
||||
|
||||
/**
|
||||
* The public constructor of the WorkflowGenerator.
|
||||
* 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.listSelector = data.selector;
|
||||
})
|
||||
this.socket.on('setPaginationMode', (data: { pagination: boolean }) => {
|
||||
this.paginationMode = data.pagination;
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -702,6 +707,24 @@ export class WorkflowGenerator {
|
||||
const selectorBasedOnCustomAction = (this.getList === true)
|
||||
? await getNonUniqueSelectors(page, coordinates, this.listSelector)
|
||||
: 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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user