testdriverai 7.3.20 → 7.3.22

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/sdk.js +44 -30
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [7.3.22](https://github.com/testdriverai/testdriverai/compare/v7.3.21...v7.3.22) (2026-02-19)
2
+
3
+
4
+
5
+ ## [7.3.21](https://github.com/testdriverai/testdriverai/compare/v7.3.20...v7.3.21) (2026-02-19)
6
+
7
+
8
+
1
9
  ## [7.3.20](https://github.com/testdriverai/testdriverai/compare/v7.3.19...v7.3.20) (2026-02-19)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.3.20",
3
+ "version": "7.3.22",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",
package/sdk.js CHANGED
@@ -1712,38 +1712,52 @@ class TestDriverSDK {
1712
1712
  */
1713
1713
  async _waitForChromeDebuggerReady(timeoutMs = 60000) {
1714
1714
  const shell = this.os === "windows" ? "pwsh" : "sh";
1715
-
1716
- if (this.os === "windows") {
1717
- // Wait for port 9222 to be listening
1718
- await this.exec(
1719
- shell,
1720
- `$timeout = ${Math.floor(timeoutMs / 1000)}; $elapsed = 0; while ($elapsed -lt $timeout) { try { $tcp = New-Object System.Net.Sockets.TcpClient; $tcp.Connect('127.0.0.1', 9222); $tcp.Close(); break } catch { Start-Sleep -Milliseconds 200; $elapsed += 0.2 } }`,
1721
- timeoutMs,
1722
- true,
1723
- );
1724
-
1725
- // Wait for a page target to appear via CDP
1726
- await this.exec(
1727
- shell,
1728
- `$timeout = ${Math.floor(timeoutMs / 1000)}; $elapsed = 0; while ($elapsed -lt $timeout) { try { $r = Invoke-RestMethod -Uri 'http://localhost:9222/json' -TimeoutSec 2; if ($r | Where-Object { $_.type -eq 'page' }) { break } } catch {} Start-Sleep -Milliseconds 500; $elapsed += 0.5 }`,
1729
- timeoutMs,
1730
- true,
1731
- );
1732
- } else {
1733
- // Wait for port 9222 to be listening
1734
- await this.exec(
1735
- shell,
1736
- `timeout=${Math.floor(timeoutMs / 1000)}; elapsed=0; while [ $elapsed -lt $timeout ]; do nc -z localhost 9222 && break; sleep 0.2; elapsed=$((elapsed + 1)); done`,
1737
- timeoutMs,
1738
- true,
1715
+ const portCheckCmd = this.os === "windows"
1716
+ ? `$tcp = New-Object System.Net.Sockets.TcpClient; $tcp.Connect('127.0.0.1', 9222); $tcp.Close(); echo 'open'`
1717
+ : `curl -s -o /dev/null --connect-timeout 2 http://localhost:9222 2>/dev/null && echo 'open' || echo 'closed'`;
1718
+ const pageCheckCmd = this.os === "windows"
1719
+ ? `(Invoke-RestMethod -Uri 'http://localhost:9222/json' -TimeoutSec 2) | Where-Object { $_.type -eq 'page' } | Select-Object -First 1 | ConvertTo-Json`
1720
+ : `curl -s http://localhost:9222/json 2>/dev/null | grep '"type": "page"'`;
1721
+
1722
+ const deadline = Date.now() + timeoutMs;
1723
+
1724
+ // Wait for port 9222 to be listening
1725
+ let portReady = false;
1726
+ while (Date.now() < deadline) {
1727
+ try {
1728
+ const result = await this.exec(shell, portCheckCmd, 5000, true);
1729
+ if (result && result.includes("open")) {
1730
+ portReady = true;
1731
+ break;
1732
+ }
1733
+ } catch (_) {
1734
+ // Port not ready yet
1735
+ }
1736
+ await new Promise((r) => setTimeout(r, 200));
1737
+ }
1738
+ if (!portReady) {
1739
+ throw new Error(
1740
+ `Chrome debugger port 9222 did not become available within ${timeoutMs}ms`,
1739
1741
  );
1742
+ }
1740
1743
 
1741
- // Wait for a page target to appear via CDP
1742
- await this.exec(
1743
- shell,
1744
- `timeout=${Math.floor(timeoutMs / 1000)}; elapsed=0; while [ $elapsed -lt $timeout ]; do curl -s http://localhost:9222/json 2>/dev/null | grep -q '"type": "page"' && break; sleep 0.5; elapsed=$((elapsed + 1)); done`,
1745
- timeoutMs,
1746
- true,
1744
+ // Wait for a page target to appear via CDP
1745
+ let pageReady = false;
1746
+ while (Date.now() < deadline) {
1747
+ try {
1748
+ const result = await this.exec(shell, pageCheckCmd, 5000, true);
1749
+ if (result && result.trim().length > 0) {
1750
+ pageReady = true;
1751
+ break;
1752
+ }
1753
+ } catch (_) {
1754
+ // No page target yet
1755
+ }
1756
+ await new Promise((r) => setTimeout(r, 500));
1757
+ }
1758
+ if (!pageReady) {
1759
+ throw new Error(
1760
+ `Chrome page target did not become available within ${timeoutMs}ms`,
1747
1761
  );
1748
1762
  }
1749
1763
  }