automation_model 1.0.41 → 1.0.43

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.
@@ -188,59 +188,59 @@ class StableBrowser {
188
188
  throw e;
189
189
  }
190
190
  }
191
- // async _getText(selector, _params = null, options = {}, info = {}) {
192
- // let element = await this._locate(selector, info, _params);
193
- // await this._screenShot(options);
194
- // return await element.textContent();
195
- // }
196
- async _getText2(selector, _params = null, options = {}, info = {}) {
191
+
192
+ async getText(selector, _params = null, options = {}, info = {}) {
193
+ if (!info.log) {
194
+ info.log = [];
195
+ }
197
196
  let element = await this._locate(selector, info, _params);
198
197
  await this._screenShot(options);
199
- let textFound = await element.evaluate((_node) => {
200
- function isInline(element) {
201
- var displayStyle = window.getComputedStyle(element, null).getPropertyValue("display");
202
- return displayStyle === "inline" || displayStyle === "inline-block";
203
- }
198
+ return await element.innerText();
199
+ // let textFound = await element.evaluate((_node) => {
200
+ // function isInline(element) {
201
+ // var displayStyle = window.getComputedStyle(element, null).getPropertyValue("display");
202
+ // return displayStyle === "inline" || displayStyle === "inline-block";
203
+ // }
204
204
 
205
- function isElementVisible(element) {
206
- if (!element.getBoundingClientRect) {
207
- return true;
208
- }
209
- const rect = element.getBoundingClientRect();
210
- if (rect.height === 0 || rect.width === 0) {
211
- return false;
212
- }
213
- const viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);
214
- return !(rect.bottom < 0 || rect.top - viewHeight >= 0);
215
- }
216
- function getVisibleText(node) {
217
- if (!isElementVisible(node)) {
218
- return "";
219
- }
220
- if (node.nodeType === Node.TEXT_NODE) {
221
- return node.nodeValue.trim();
222
- }
223
- if (node.nodeType !== Node.ELEMENT_NODE) {
224
- return "";
225
- }
226
- let block = !isInline(node);
227
- let text = "";
228
- for (let child of node.childNodes) {
229
- text += getVisibleText(child);
230
- }
231
- if (block) {
232
- text += "\n";
233
- } else {
234
- text = " " + text;
235
- }
236
- return text;
237
- }
238
- return getVisibleText(_node).trim();
239
- });
240
- return textFound
241
- .split("\n")
242
- .filter((line) => line.trim() !== "")
243
- .join("\n");
205
+ // function isElementVisible(element) {
206
+ // if (!element.getBoundingClientRect) {
207
+ // return true;
208
+ // }
209
+ // const rect = element.getBoundingClientRect();
210
+ // if (rect.height === 0 || rect.width === 0) {
211
+ // return false;
212
+ // }
213
+ // const viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);
214
+ // return !(rect.bottom < 0 || rect.top - viewHeight >= 0);
215
+ // }
216
+ // function getVisibleText(node) {
217
+ // if (!isElementVisible(node)) {
218
+ // return "";
219
+ // }
220
+ // if (node.nodeType === Node.TEXT_NODE) {
221
+ // return node.nodeValue.trim();
222
+ // }
223
+ // if (node.nodeType !== Node.ELEMENT_NODE) {
224
+ // return "";
225
+ // }
226
+ // let block = !isInline(node);
227
+ // let text = "";
228
+ // for (let child of node.childNodes) {
229
+ // text += getVisibleText(child);
230
+ // }
231
+ // if (block) {
232
+ // text += "\n";
233
+ // } else {
234
+ // text = " " + text;
235
+ // }
236
+ // return text;
237
+ // }
238
+ // return getVisibleText(_node).trim();
239
+ // });
240
+ // return textFound
241
+ // .split("\n")
242
+ // .filter((line) => line.trim() !== "")
243
+ // .join("\n");
244
244
  }
245
245
 
246
246
  async containsText(selector, text, _params = null, options = {}) {
@@ -250,7 +250,7 @@ class StableBrowser {
250
250
  info.selector = selector;
251
251
  info.value = text;
252
252
  try {
253
- let foundText = await this._getText2(selector, _params, options, info);
253
+ let foundText = await this.getText(selector, _params, options, info);
254
254
  if (!foundText.includes(text)) {
255
255
  info.foundText = foundText;
256
256
  throw new Error("element doesn't contain text " + text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automation_model",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "An automation infrastructure module to be use for generative AI automation projects.",
5
5
  "main": "bin/index.js",
6
6
  "type": "module",