Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add js sdk folder to fish-tank #75

Merged
merged 26 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0c25cb0
Add js sdk folder to fish-tank
frankfeng98 Oct 28, 2024
7b4f43f
Update formatting
frankfeng98 Oct 28, 2024
9de8235
Add placeholder files
frankfeng98 Oct 28, 2024
66c82e3
Update naming of the file
frankfeng98 Oct 28, 2024
c9ea375
Add one more example
frankfeng98 Oct 29, 2024
8ee3b01
kate/tf 3913 application collect ecommerce pricing data (#81)
KateZhang98 Oct 29, 2024
380c262
Add js example for list query usage (#83)
thakkerurvish Oct 30, 2024
a03e11a
add save / load authenticated session js sdk example. ran script and…
lozzle Oct 30, 2024
4477e87
Add close-popup files (#76)
SuveenE-TF Oct 30, 2024
384a67a
Close cookie popup js sdk (#77)
aarontantf Oct 30, 2024
2b5f1b4
Add log-into-sites examples (#79)
SuveenE-TF Oct 30, 2024
2bb7af2
Compare Product Prices Example (#78)
jinyangTF Oct 31, 2024
f02afc4
Add headless browser script (#85)
Zechereh Oct 31, 2024
09399d2
Add Getting Started YT script (#90)
colriot Nov 1, 2024
010f559
Add wait for entire page to load example script
Zechereh Nov 1, 2024
2cdd115
Js stealth mode example (#80)
TinyGambe Nov 4, 2024
5f7527c
Add xpath application example (#92)
Zechereh Nov 4, 2024
1dc3197
Added javascript sentiment analysis script (#94)
Zechereh Nov 4, 2024
408ac66
Add wait for entire page to load example script (#95)
Zechereh Nov 4, 2024
ad248ac
submit form js example (#89)
joshkung247 Nov 5, 2024
7eb3413
Add get_by_prompt example
frankfeng98 Nov 5, 2024
ec4bdb6
Merge branch 'add_js_sdk_examples_folder' of github.com:tinyfish-io/f…
frankfeng98 Nov 5, 2024
085e4a7
Fix formatting
frankfeng98 Nov 5, 2024
1a7d682
add interact with existing browser example
frankfeng98 Nov 5, 2024
ce9ad3f
Update interact with existing browser example
frankfeng98 Nov 5, 2024
f024082
address comments & fix examples
frankfeng98 Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add get_by_prompt example
  • Loading branch information
frankfeng98 committed Nov 5, 2024
commit 7eb3413f5c7f904fccad9ec209d9bc49e04c376d
4 changes: 2 additions & 2 deletions javascript-sdk/examples/first-steps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This is an example of collecting pricing data from e-commerce website using Agen
## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/javascript-sdk/installation)
- Save this JavaScript file locally as **first_steps.js**
- Save this JavaScript file locally as **first-steps.js**
- Run the following command from the project's folder:

```bash
node first_steps.js
node first-steps.js
```

## Play with the query
Expand Down
17 changes: 17 additions & 0 deletions javascript-sdk/examples/get-by-prompt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Example script: interact with elements leveraging getByPrompt method

This is an example of levergaing getByPrompt() method to retrieve an element and interact with it using AgentQL.

## Run the script

- [Install AgentQL SDK](https://docs.agentql.com/javascript-sdk/installation)
- Save this Javascript file locally as **get-by-prompt.js**
- Run the following command from the project's folder:

```bash
node get-by-prompt.js
```

## Play with the query

Install the [AgentQL Debugger Chrome extension](https://docs.agentql.com/installation/chrome-extension-installation) to play with the AgentQL query. [Learn more about the AgentQL query language](https://docs.agentql.com/agentql-query/query-intro)
37 changes: 37 additions & 0 deletions javascript-sdk/examples/get-by-prompt/get-by-prompt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This example demonstrates how to leverage get_by_prompt method to interact with element by prompt text.

const { wrap, configure } = require('agentql');
const { chromium } = require('playwright');

// Set the URL to the desired website
const URL = 'https://thinking-tester-contact-list.herokuapp.com/';

async function main() {
// Configure the AgentQL API key
configure({
apiKey: process.env.AGENTQL_API_KEY, // This is the default and can be omitted.
});

const browser = await chromium.launch({ headless: false });

// Wrap the page to get access to the AgentQL's querying API
const page = await wrap(await browser.newPage());

// Navigate to the URL
await page.goto(URL);

// Get the sign up button by the prompt text
const signUpBtn = await page.getByPrompt('Sign up button');

// Click the sign up button if it exists
if (signUpBtn) {
await signUpBtn.click();
}

// Used only for demo purposes. It allows you to see the effect of the script.
await page.waitForTimeout(10000);

await browser.close();
}

main();
2 changes: 1 addition & 1 deletion javascript-sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion javascript-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prettier": "^2.8.7"
},
"dependencies": {
"agentql": "^0.0.1",
"agentql": "latest",
"openai": "^4.70.1",
"playwright": "^1.48.2",
"playwright-dompath": "^0.0.7"
Expand Down