Merge pull request #257 from getmaxun/item0-fix

feat: add check for selector visibility, revert domcontentloaded to networkidle state
This commit is contained in:
Karishma Shukla
2024-12-14 21:25:25 +05:30
committed by GitHub
3 changed files with 18 additions and 13 deletions

View File

@@ -29,12 +29,9 @@ Maxun lets you train a robot in 2 minutes and scrape the web on auto-pilot. Web
<img src="https://static.scarf.sh/a.png?x-pxid=c12a77cc-855e-4602-8a0f-614b2d0da56a" /> <img src="https://static.scarf.sh/a.png?x-pxid=c12a77cc-855e-4602-8a0f-614b2d0da56a" />
> Note: Maxun is in its early stages of development and currently does not support self-hosting. However, you can run Maxun locally. Self-hosting capabilities are planned for a future release and will be available soon. # Installation
# Local Installation
### Docker Compose ### Docker Compose
``` ```
git clone https://github.com/getmaxun/maxun
docker-compose up -d docker-compose up -d
``` ```
You can access the frontend at http://localhost:5173/ and backend at http://localhost:8080/ You can access the frontend at http://localhost:5173/ and backend at http://localhost:8080/

View File

@@ -64,8 +64,6 @@ services:
- redis - redis
- minio - minio
volumes: volumes:
- ./server:/app/server # Mount server source code for hot reloading
- ./maxun-core:/app/maxun-core # Mount maxun-core for any shared code updates
- /var/run/dbus:/var/run/dbus - /var/run/dbus:/var/run/dbus
frontend: frontend:
@@ -79,9 +77,6 @@ services:
environment: environment:
PUBLIC_URL: ${PUBLIC_URL} PUBLIC_URL: ${PUBLIC_URL}
BACKEND_URL: ${BACKEND_URL} BACKEND_URL: ${BACKEND_URL}
volumes:
- ./:/app # Mount entire frontend app directory for hot reloading
- /app/node_modules # Anonymous volume to prevent overwriting node_modules
depends_on: depends_on:
- backend - backend

View File

@@ -192,8 +192,8 @@ export default class Interpreter extends EventEmitter {
// const actionable = async (selector: string): Promise<boolean> => { // const actionable = async (selector: string): Promise<boolean> => {
// try { // try {
// const proms = [ // const proms = [
// page.isEnabled(selector, { timeout: 5000 }), // page.isEnabled(selector, { timeout: 10000 }),
// page.isVisible(selector, { timeout: 5000 }), // page.isVisible(selector, { timeout: 10000 }),
// ]; // ];
// return await Promise.all(proms).then((bools) => bools.every((x) => x)); // return await Promise.all(proms).then((bools) => bools.every((x) => x));
@@ -215,6 +215,17 @@ export default class Interpreter extends EventEmitter {
// }), // }),
// ).then((x) => x.flat()); // ).then((x) => x.flat());
const presentSelectors: SelectorArray = await Promise.all(
selectors.map(async (selector) => {
try {
await page.waitForSelector(selector, { state: 'attached' });
return [selector];
} catch (e) {
return [];
}
}),
).then((x) => x.flat());
const action = workflowCopy[workflowCopy.length - 1]; const action = workflowCopy[workflowCopy.length - 1];
// console.log("Next action:", action) // console.log("Next action:", action)
@@ -233,7 +244,7 @@ export default class Interpreter extends EventEmitter {
...p, ...p,
[cookie.name]: cookie.value, [cookie.name]: cookie.value,
}), {}), }), {}),
selectors, selectors: presentSelectors,
}; };
} }
@@ -768,6 +779,8 @@ export default class Interpreter extends EventEmitter {
this.log('Starting the workflow.', Level.LOG); this.log('Starting the workflow.', Level.LOG);
const context = page.context(); const context = page.context();
page.setDefaultNavigationTimeout(100000);
// Check proxy settings from context options // Check proxy settings from context options
const contextOptions = (context as any)._options; const contextOptions = (context as any)._options;
const hasProxy = !!contextOptions?.proxy; const hasProxy = !!contextOptions?.proxy;