web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / use jquery in run java...
Power Automate
Answered

use jquery in run javascript under power automate desktop

(0) ShareShare
ReportReport
Posted on by 44

As we all know behind the scenes power automate uses jquery selectors for web automation. I was trying to get the elements using jquery selector under step run javascript for web page, in following fashion:

 

var count = $("ul.class1").childElementCount;

return count

 

but above code always returns unknown. Whereas same code works on browser console of the respective webpage.

 

Can anyone suggest what is wrong here.

 

Thanks

I have the same question (0)
  • pawanrai Profile Picture
    44 on at

    Anyone having any sort of inputs please

  • joergh Profile Picture
    46 on at

    Hi i am also starting at the time , i read yeasterday that only a few selectors are avaliable  like :contains . If you have something with text to click or mark the mouse move to text function realy good . The rest i did with keyboard shortcuts tap , windows short cuts . So i didnt need the selectors yet.   here is a video https://youtu.be/cgK_BH1gBzc?t=5707 that nice programmer used selectors.  What i figured out was espacialy the events from browser automate didnt work  good , but the events at the mouse do . 

     

  • pawanrai Profile Picture
    44 on at

    Thanks for inputs

  • Verified answer
    pawanrai Profile Picture
    44 on at

    Okay. This is where the issue was. The respective html document was inside an iframe and I was overlooking this fact.

     

    I had to use below js code to reach the respective element:

     

    var iFrameDOM = $("iframe#iframeid").contents();
    var li = iFrameDOM.find("li.css-class").length;

     

    The above code worked and gather the correct count.

     

  • joergh Profile Picture
    46 on at

    Hey great you share this , i need to try out 🙂 I start loving Power Automate, it is also possible to record, and record twice and do both in one selection. I made an example page to get  css selectors by using power automate. I will update from time to time.  

  • maxpower45255 Profile Picture
    223 on at

    I have a JQuery function I'm trying to implement. The function works fine in the browser console.
    But it returns nothing when I execute it in Power Automate Desktop
    using the "Execute Javascript function on a web page" action.
    So I started playing with just this simple JS function (which also doesn't return anything):

    function ExecuteScript() {var data = "This is a test"; return data;}

    Any thoughts on what is happening with this action?

    I'm dealing with dynamically generated elements on the web page and can't rely on static IDs.
    I have to loop through rows of input fields. So having an action to call Javascript or JQuery would be a huge help. 

    Thanks!

  • joergh Profile Picture
    46 on at

    Maybe this is what you searching for WScript.Echo(MyJavascriptVariableForJavascriptOutput);

    I don't think you can work with jquery in power automate ! Tried it then. When something looks like jquery it doesn't have the same behavior as on webpages nor the same syntax I think.

    // Delete Zero at begining String->var stringel

    var stringel="%NewVar%";  // "%InputVariableFromPowerAutomate%";

    var replaced = ""+stringel.substring(1);
     
    WScript.Echo(replaced); /* replaced is the javascript variable who will be shown in JavascriptOutput */

  • joergh Profile Picture
    46 on at

    Example for Copy Paste into Main ->SET NewVar TO $'''0123004'''
    Scripting.RunJavascript JavascriptCode: $'''// Lösche voranstehende Null bzw erstes Zeichen in der Zeichenkette

    var stringel=\"%NewVar%\";


    var replaced = \"\"+stringel.substring(1);


    WScript.Echo(replaced);''' ScriptOutput=> JavascriptOutput ScriptError=> ScriptError<-End of Code

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 796

#2
Valantis Profile Picture

Valantis 671

#3
Haque Profile Picture

Haque 551

Last 30 days Overall leaderboard