TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    JS SyntaxError

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 415 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G Offline
      Guilherme Oliveira
      last edited by

      Hi,
      I'm trying to run a JS file but I can't get it to work with TriggerCMD
      The JS file works fine if I run it manually
      I even tried to use a .bat, but it's not working either
      here's the .bat example

      node C:\Users\XPTO\Desktop\Workspace\bot-ponto\index.js
      

      I always get the following error

      C:\Users\XPTO\AppData\Local\TRIGGERcmdAgent\app-1.0.25\resources\app\src>node C:\Users\XPTO\Desktop\\Workspace\bot-ponto\index.js
      C:\Users\XPTO\Desktop\\Workspace\bot-ponto\index.js:9
      .then(async (browser) => {
                  
      SyntaxError: Unexpected token (
          at Object.exports.runInThisContext (vm.js:76:16)
          at Module._compile (module.js:542:28)
          at Object.Module._extensions..js (module.js:579:10)
          at Module.load (module.js:487:32)
          at tryModuleLoad (module.js:446:12)
          at Function.Module._load (module.js:438:3)
          at Module.runMain (module.js:604:10)
          at run (bootstrap_node.js:394:7)
          at startup (bootstrap_node.js:149:9)
          at bootstrap_node.js:509:3
      

      and this is the code I'm trying to run

      const puppeteer = require("puppeteer-extra");
      const StealthPlugin = require("puppeteer-extra-plugin-stealth");
      
      const user = 'user';
      const password = 'pass';
      
      puppeteer.use(StealthPlugin());
      puppeteer.launch({ headless: true })
      .then(async (browser) => {
          const page = await browser.newPage();
      	
          await page.goto("pageURL");
      	
          await page.click("#Login");
          await page.keyboard.type(user);
      	
          await page.click("#Senha");
          await page.keyboard.type(password);
      	
          await page.click(
            "body > div.container.body-content.text-center > div > form > div > div.card-body > div:nth-child(2) > div.form-group.col-md-3.col-sm-12 > input"
      	);
      	
      
          await page.waitForSelector("#conteudo > div.form-row > div:nth-child(1) > a");
      	await page.click("#conteudo > div.form-row > div:nth-child(1) > a");
      	setTimeout(async()=>{
      	await page.$eval("#nvlEntrada", (el) => (el.value = "09:00"));
      	await page.$eval("#nvlAlmoco", (el) => (el.value = "12:00"));
          await page.$eval("#nvlRetorno", (el) => (el.value = "13:00"));
          await page.$eval("#nvlSaida", (el) => (el.value = "18:00"));
          await page.$eval("#ccdComposto", (el) => (el.value = "924;33"));
          await page.$eval("#cdsApontamento", (el) => (el.value = "Alocação"));
          await page.click("#btnGravarContinuar");
          
          await page.waitForSelector("#exampleModal > div > div > div.modal-body");
          
          await browser.close()
      	},5000)
        }).catch(err => console.log(err));
      
      

      Does anyone know what that might be?
      Thx for the help!

      RussR 1 Reply Last reply Reply Quote 0
      • RussR Offline
        Russ @Guilherme Oliveira
        last edited by Russ

        @Guilherme-Oliveira said in JS SyntaxError:

        node C:\Users\XPTO\Desktop\Workspace\bot-ponto\index.js

        Please try this for your batch file:

        c:
        cd C:\Users\XPTO\Desktop\Workspace\bot-ponto
        node index.js
        

        If that doesn't work, please run where node to get the path to node like this:

        C:\>where node
        C:\Program Files\nodejs\node.exe
        

        Then use the full path to node.exe in your batch file like this:

        c:
        cd C:\Users\XPTO\Desktop\Workspace\bot-ponto
        "C:\Program Files\nodejs\node.exe" index.js
        

        Russell VanderMey

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post