feat: add nth-child selectors for td tag
This commit is contained in:
@@ -869,6 +869,13 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
|
||||
function getNonUniqueSelector(element: HTMLElement): string {
|
||||
let selector = element.tagName.toLowerCase();
|
||||
|
||||
if (selector === 'td' && element.parentElement) {
|
||||
// Find position among td siblings
|
||||
const siblings = Array.from(element.parentElement.children);
|
||||
const position = siblings.indexOf(element) + 1;
|
||||
return `${selector}:nth-child(${position})`;
|
||||
}
|
||||
|
||||
if (element.className) {
|
||||
const classes = element.className.split(/\s+/).filter((cls: string) => Boolean(cls));
|
||||
if (classes.length > 0) {
|
||||
@@ -937,6 +944,12 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
|
||||
function getNonUniqueSelector(element: HTMLElement): string {
|
||||
let selector = element.tagName.toLowerCase();
|
||||
|
||||
if (selector === 'td' && element.parentElement) {
|
||||
const siblings = Array.from(element.parentElement.children);
|
||||
const position = siblings.indexOf(element) + 1;
|
||||
return `${selector}:nth-child(${position})`;
|
||||
}
|
||||
|
||||
if (element.className) {
|
||||
const classes = element.className.split(/\s+/).filter((cls: string) => Boolean(cls));
|
||||
if (classes.length > 0) {
|
||||
@@ -991,6 +1004,12 @@ export const getChildSelectors = async (page: Page, parentSelector: string): Pro
|
||||
function getNonUniqueSelector(element: HTMLElement): string {
|
||||
let selector = element.tagName.toLowerCase();
|
||||
|
||||
if (selector === 'td' && element.parentElement) {
|
||||
const siblings = Array.from(element.parentElement.children);
|
||||
const position = siblings.indexOf(element) + 1;
|
||||
return `${selector}:nth-child(${position})`;
|
||||
}
|
||||
|
||||
const className = typeof element.className === 'string' ? element.className : '';
|
||||
if (className) {
|
||||
const classes = className.split(/\s+/).filter((cls: string) => Boolean(cls));
|
||||
|
||||
Reference in New Issue
Block a user