@letsscrapedata/controller 0.0.31 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -179,8 +179,8 @@ var PlaywrightElement = class _PlaywrightElement {
179
179
  }
180
180
  try {
181
181
  let locators = [];
182
- if (selector.startsWith("./") || selector.startsWith("/")) {
183
- locators = await parent2.locator(selector).all();
182
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
183
+ locators = await parent2.locator(`xpath=${selector}`).all();
184
184
  } else {
185
185
  if (selector !== ".") {
186
186
  locators = await parent2.locator(selector).all();
@@ -524,8 +524,8 @@ var PlaywrightPage = class extends import_node_events.default {
524
524
  }
525
525
  try {
526
526
  let locators = [];
527
- if (selector.startsWith("./") || selector.startsWith("/")) {
528
- locators = await frame.locator(selector).all();
527
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
528
+ locators = await frame.locator(`xpath=${selector}`).all();
529
529
  } else {
530
530
  if (selector !== ".") {
531
531
  locators = await frame.locator(selector).all();
@@ -1687,11 +1687,13 @@ var PuppeteerElement = class _PuppeteerElement {
1687
1687
  return retObj;
1688
1688
  }
1689
1689
  retObj.frame = frame;
1690
+ absolute = true;
1690
1691
  parent2 = frame;
1691
1692
  }
1692
1693
  try {
1693
- if (selector.startsWith("./") || selector.startsWith("/")) {
1694
- retObj.elementHandles = await parent2.$$(selector);
1694
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
1695
+ const newSelector = !absolute && selector.startsWith("/") ? `.${selector}` : selector;
1696
+ retObj.elementHandles = await parent2.$$(`::-p-xpath(${newSelector})`);
1695
1697
  } else {
1696
1698
  if (selector !== ".") {
1697
1699
  retObj.elementHandles = await parent2.$$(selector);
@@ -2013,8 +2015,8 @@ var PuppeteerPage = class extends import_node_events4.default {
2013
2015
  retObj.frame = frame;
2014
2016
  }
2015
2017
  try {
2016
- if (selector.startsWith("./") || selector.startsWith("/")) {
2017
- retObj.elementHandles = await frame.$$(selector);
2018
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
2019
+ retObj.elementHandles = await frame.$$(`::-p-xpath(${selector})`);
2018
2020
  } else {
2019
2021
  if (selector !== ".") {
2020
2022
  retObj.elementHandles = await frame.$$(selector);
package/dist/index.js CHANGED
@@ -159,8 +159,8 @@ var PlaywrightElement = class _PlaywrightElement {
159
159
  }
160
160
  try {
161
161
  let locators = [];
162
- if (selector.startsWith("./") || selector.startsWith("/")) {
163
- locators = await parent2.locator(selector).all();
162
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
163
+ locators = await parent2.locator(`xpath=${selector}`).all();
164
164
  } else {
165
165
  if (selector !== ".") {
166
166
  locators = await parent2.locator(selector).all();
@@ -504,8 +504,8 @@ var PlaywrightPage = class extends EventEmitter {
504
504
  }
505
505
  try {
506
506
  let locators = [];
507
- if (selector.startsWith("./") || selector.startsWith("/")) {
508
- locators = await frame.locator(selector).all();
507
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
508
+ locators = await frame.locator(`xpath=${selector}`).all();
509
509
  } else {
510
510
  if (selector !== ".") {
511
511
  locators = await frame.locator(selector).all();
@@ -1667,11 +1667,13 @@ var PuppeteerElement = class _PuppeteerElement {
1667
1667
  return retObj;
1668
1668
  }
1669
1669
  retObj.frame = frame;
1670
+ absolute = true;
1670
1671
  parent2 = frame;
1671
1672
  }
1672
1673
  try {
1673
- if (selector.startsWith("./") || selector.startsWith("/")) {
1674
- retObj.elementHandles = await parent2.$$(selector);
1674
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
1675
+ const newSelector = !absolute && selector.startsWith("/") ? `.${selector}` : selector;
1676
+ retObj.elementHandles = await parent2.$$(`::-p-xpath(${newSelector})`);
1675
1677
  } else {
1676
1678
  if (selector !== ".") {
1677
1679
  retObj.elementHandles = await parent2.$$(selector);
@@ -1993,8 +1995,8 @@ var PuppeteerPage = class extends EventEmitter4 {
1993
1995
  retObj.frame = frame;
1994
1996
  }
1995
1997
  try {
1996
- if (selector.startsWith("./") || selector.startsWith("/")) {
1997
- retObj.elementHandles = await frame.$$(selector);
1998
+ if (selector.startsWith("./") || selector.startsWith("/") || selector.startsWith("..")) {
1999
+ retObj.elementHandles = await frame.$$(`::-p-xpath(${selector})`);
1998
2000
  } else {
1999
2001
  if (selector !== ".") {
2000
2002
  retObj.elementHandles = await frame.$$(selector);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsscrapedata/controller",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "Unified browser / HTML controller interfaces that support playwright, puppeteer and cheerio",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",