Skip to content

Commit

Permalink
Merge pull request #32 from xoFeulB/v0.5
Browse files Browse the repository at this point in the history
V0.5
  • Loading branch information
ibuninngu committed Mar 10, 2024
2 parents 4aedda6 + 4bfe60d commit 8322c14
Show file tree
Hide file tree
Showing 7 changed files with 463 additions and 335 deletions.
File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,29 @@ BlueFox is a web front-end test automation and operational knowledge sharing sol
(async () => {
let blueFoxScript = await new BlueFoxScript();

let tab = await blueFoxScript.tabs.create("https://www.google.com");
await tab.dispatch
let tab = await blueFoxScript.createWindow("https://www.google.com");
await tab
.tails()
.target("textarea")
.setProperty({ value: "^.,.^ BlueFox" })
.target("[name='btnK'][tabindex='0']")
.call("click", null)
.runTillNextOnLoad({ sleep: 50 });

let search_result = await tab.dispatch.script(() => {
return [
...document.querySelectorAll("#search :is(a[data-jsarwt='1'],a[jsname])"),
]
.filter((_) => {
return _.querySelector("h3");
})
.map((_) => {
return {
href: _.href,
title: _.querySelector("h3").textContent,
};
});
});
let search_result = await tab.dispatchScript(
() => {
return [...document.querySelectorAll("#search :is(a[data-jsarwt='1'],a[jsname])")]
.filter((_) => {
return _.querySelector("h3");
})
.map((_) => {
return {
href: _.href,
title: _.querySelector("h3").textContent,
}
});
}
);
window.alert(JSON.stringify(search_result.result.value, null, 4));
})();
```
Expand Down Expand Up @@ -146,7 +146,7 @@ in cloned BlueFox.git directory
git pull
```

### CreateShortcut to Chrome and install BlueFox
### CreateShortcut to Chrome and install BlueFox with new user data
Windows PowerShell
```powershell
.\CreateShortcut-Chrome.ps1
Expand Down
76 changes: 36 additions & 40 deletions docs/help/Scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,31 +91,30 @@ Run String:script
(async () => {
let blueFoxScript = await new BlueFoxScript();

tab = await blueFoxScript.tabs.info[0];
tab = await blueFoxScript.tabs.create(
tab = await blueFoxScript.createWindow(
"https://ooo.bluefox.ooo/BlueFoxDemo/8bit.html"
);

await blueFoxScript.tabs.reload();
tab = await blueFoxScript.tabs.get(
tab = await blueFoxScript.findTab(
"https://ooo.bluefox.ooo/BlueFoxDemo/8bit.html"
)[0];

// Property
tab.url;
tab.dispatch;
tab.info;
tab.responses;
tab.keepResponses;
})();
```

</bluefoxscript>

### BlueFoxScript.tabs.info[n].dispatch.tails() ... Method chaining
### BlueFoxScript[tabId].tails() ... Method chaining

<bluefoxscript>

```javascript
(async () => {
let tails = tab.dispatch.tails({
let tails = tab.tails({
sleep: 100,
dispatchEvents: [
{
Expand Down Expand Up @@ -381,7 +380,6 @@ sleep millisecond
})();
```


</bluefoxscript>

#### .run()
Expand Down Expand Up @@ -412,13 +410,13 @@ run Tails and await till next window.onload

</bluefoxscript>

### BlueFoxScript.tabs.info[n].dispatch.addEventListeners()
### BlueFoxScript[tabId].addEventListeners()

<bluefoxscript>

```javascript
(async () => {
let listener_info = await tab.dispatch.addEventListeners(
let listener_info = await tab.addEventListeners(
`[data-testid="bit-1"]`,
"click",
async (object) => {
Expand All @@ -439,55 +437,55 @@ run Tails and await till next window.onload

</bluefoxscript>

### BlueFoxScript.tabs.info[n].dispatch.script()
### BlueFoxScript[tabId].dispatchScript()

<bluefoxscript>

```javascript
(async () => {
await tab.dispatch.script(() => {
await tab.dispatchScript(() => {
window.alert("^.,.^ BlueFox");
});
})();
```

</bluefoxscript>

### BlueFoxScript.tabs.info[n].dispatch.tillScriptTrue()
### BlueFoxScript[tabId].dispatchScriptTillTrue()

<bluefoxscript>

```javascript
(async () => {
await tab.dispatch.tillScriptTrue(() => {
await tab.dispatchScriptTillTrue(() => {
return true;
}, (max_polling = 5000));
})();
```

</bluefoxscript>

### BlueFoxScript.tabs.info[n].dispatch.action()
### BlueFoxScript[tabId].dispatchAction()

run Tails

<bluefoxscript>

```javascript
(async () => {
await tab.dispatch.action(tails.tail);
await tab.dispatchAction(tails.tail);
})();
```

</bluefoxscript>

### BlueFoxScript.tabs.info[n].dispatch.screenshot()
### BlueFoxScript[tabId].captureScreenshot()

<bluefoxscript>

```javascript
(async () => {
let base64_png_image = await tab.dispatch.screenshot(
let base64_png_image = await tab.captureScreenshot(
(config = {
format: "png",
captureBeyondViewport: true,
Expand All @@ -498,7 +496,7 @@ run Tails

</bluefoxscript>

### BlueFoxScript.tabs.info[n].close()
### BlueFoxScript[tabId].close()

<bluefoxscript>

Expand All @@ -510,7 +508,7 @@ run Tails

</bluefoxscript>

### BlueFoxScript.tabs.info[n].reload()
### BlueFoxScript[tabId].reload()

<bluefoxscript>

Expand All @@ -522,49 +520,48 @@ run Tails

</bluefoxscript>

### BlueFoxScript.tabs.info[n].getCookies()
### BlueFoxScript[tabId].cookie.get()

https://developer.chrome.com/docs/extensions/reference/api/cookies#method-getAll

<bluefoxscript>

```javascript
(async () => {
await tab.getCookies({ domain: "domain" });
await tab.cookie.get({ domain: "domain" });
})();
```

</bluefoxscript>

### BlueFoxScript.tabs.info[n].removeCookie()
### BlueFoxScript[tabId].cookie.remove()

https://developer.chrome.com/docs/extensions/reference/api/cookies#method-remove

<bluefoxscript>

```javascript
(async () => {
await tab.removeCookie({ name: "name" });
await tab.cookie.remove({ name: "name" });
})();
```

</bluefoxscript>

### BlueFoxScript.tabs.info[n].setCookie()
### BlueFoxScript[tabId].cookie.set()

https://developer.chrome.com/docs/extensions/reference/api/cookies#method-set

<bluefoxscript>

```javascript
(async () => {
await tab.setCookie({ name: "name", value: "value" });
await tab.cookie.set({ name: "name", value: "value" });
})();
```

</bluefoxscript>


## Step by Step

### 1. Inside async function
Expand Down Expand Up @@ -599,7 +596,7 @@ https://developer.chrome.com/docs/extensions/reference/api/cookies#method-set
(async () => {
let blueFoxScript = await new BlueFoxScript();

let tab = await blueFoxScript.tabs.create("https://www.google.com");
let tab = await blueFoxScript.createWindow("https://www.google.com");
})();
```

Expand All @@ -613,9 +610,9 @@ https://developer.chrome.com/docs/extensions/reference/api/cookies#method-set
(async () => {
let blueFoxScript = await new BlueFoxScript();

let tab = await blueFoxScript.tabs.create("https://www.google.com");
let tab = await blueFoxScript.createWindow("https://www.google.com");

let tails = await tab.dispatch.tails();
let tails = await tab.tails();
})();
```

Expand All @@ -629,9 +626,9 @@ https://developer.chrome.com/docs/extensions/reference/api/cookies#method-set
(async () => {
let blueFoxScript = await new BlueFoxScript();

let tab = await blueFoxScript.tabs.create("https://www.google.com");
let tab = await blueFoxScript.createWindow("https://www.google.com");

let tails = await tab.dispatch.tails();
let tails = await tab.tails();
tails
.target("textarea")
.setProperty({ value: "^.,.^ BlueFox" })
Expand All @@ -650,9 +647,9 @@ https://developer.chrome.com/docs/extensions/reference/api/cookies#method-set
(async () => {
let blueFoxScript = await new BlueFoxScript();

let tab = await blueFoxScript.tabs.create("https://www.google.com");
let tab = await blueFoxScript.createWindow("https://www.google.com");

let tails = await tab.dispatch.tails();
let tails = await tab.tails();
tails
.target("textarea")
.setProperty({ value: "^.,.^ BlueFox" })
Expand All @@ -673,19 +670,18 @@ https://developer.chrome.com/docs/extensions/reference/api/cookies#method-set
(async () => {
let blueFoxScript = await new BlueFoxScript();

let tab = await blueFoxScript.tabs.create("https://www.google.com");
let tab = await blueFoxScript.createWindow("https://www.google.com");

let tails = await tab.dispatch.tails();
let tails = await tab.tails();
tails
.target("textarea")
.setProperty({ value: "^.,.^ BlueFox" })
.target("[name='btnK'][tabindex='0']")
.call("click", null);

await tails.run({ sleep: 50 });
await tails.runTillNextOnLoad({ sleep: 50 });

await sleep(1000);
let search_result = await tab.dispatch.script(() => {
let search_result = await tab.dispatchScript(() => {
return [
...document.querySelectorAll("#search :is(a[data-jsarwt='1'],a[jsname])"),
]
Expand Down
Loading

0 comments on commit 8322c14

Please sign in to comment.