Neon-AI commited on
Commit
b4e09c9
·
verified ·
1 Parent(s): 2ec7f7d

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +7 -22
index.js CHANGED
@@ -5,9 +5,8 @@ const { chromium } = require('playwright');
5
  headless: true,
6
  args: ['--no-sandbox', '--disable-setuid-sandbox']
7
  });
8
-
9
  const page = await browser.newPage();
10
-
11
  try {
12
  await page.goto('https://en.ephoto360.com/create-3d-colorful-paint-text-effect-online-801.html', {
13
  waitUntil: 'domcontentloaded',
@@ -17,34 +16,20 @@ const { chromium } = require('playwright');
17
  await page.waitForSelector('input[name="text[]"]', { timeout: 30000 });
18
  await page.fill('input[name="text[]"]', 'TEST TEXT');
19
 
20
- await page.waitForSelector('input[type="submit"][value="GO"]');
21
  await page.click('input[type="submit"][value="GO"]');
22
 
23
- await page.waitForTimeout(10000); // generation delay
24
-
25
- await page.waitForSelector('img[src*="uploads"][src*="worigin"]', {
26
- timeout: 45000,
27
- state: 'visible'
28
- });
29
 
30
  const imageUrl = await page.evaluate(() => {
31
- const imgs = document.querySelectorAll('img[src*="uploads"]');
32
- for (const img of imgs) {
33
- if (img.src.includes('worigin') || img.src.includes('result')) {
34
- return img.src;
35
- }
36
- }
37
- return null;
38
  });
39
 
40
  console.log('Generated image:', imageUrl || 'not found');
41
 
42
- if (imageUrl) {
43
- console.log('Success');
44
- } else {
45
- await page.screenshot({ path: 'failure.png', fullPage: true });
46
- console.log('Screenshot saved → failure.png');
47
- }
48
 
49
  } catch (err) {
50
  console.error('Error:', err.message);
 
5
  headless: true,
6
  args: ['--no-sandbox', '--disable-setuid-sandbox']
7
  });
 
8
  const page = await browser.newPage();
9
+
10
  try {
11
  await page.goto('https://en.ephoto360.com/create-3d-colorful-paint-text-effect-online-801.html', {
12
  waitUntil: 'domcontentloaded',
 
16
  await page.waitForSelector('input[name="text[]"]', { timeout: 30000 });
17
  await page.fill('input[name="text[]"]', 'TEST TEXT');
18
 
 
19
  await page.click('input[type="submit"][value="GO"]');
20
 
21
+ await page.waitForTimeout(30000); // longer wait for generation
 
 
 
 
 
22
 
23
  const imageUrl = await page.evaluate(() => {
24
+ const imgs = [...document.querySelectorAll('img[src*="uploads"]')];
25
+ return imgs.find(img =>
26
+ img.src.includes('worigin') || img.src.includes('result')
27
+ )?.src || null;
 
 
 
28
  });
29
 
30
  console.log('Generated image:', imageUrl || 'not found');
31
 
32
+ if (!imageUrl) await page.screenshot({ path: 'debug.png', fullPage: true });
 
 
 
 
 
33
 
34
  } catch (err) {
35
  console.error('Error:', err.message);