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 / How to read global var...
Power Automate
Unanswered

How to read global variable from javascript

(0) ShareShare
ReportReport
Posted on by 2

Hello,

I can find a lots of examples how to extract text/data from webpage with power automate.

 

But, I cannot find any example how, from the webpage read a global variable (which is defined in javascript file)

I know the names of the these global variables which I want to read, but I don't know how.

 

Please, help

 

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @SuperDragonfly 

     

    Please check out the link below to see if it addresses your query:

    https://stackoverflow.com/questions/76113217/displaying-power-automate-variable-text-in-web-browser-via-javascript-run-javas

     

    If this doesn't provide the solution you're looking for, kindly provide additional details along with a sample site where a global variable is declared in JavaScript. We'll do our best to assist you further.

     

     

  • SuperDragonfly Profile Picture
    2 on at

    @Deenuji  It looks that your suggestion does something opposite to what I need.

    It takes variable from power automate and send it to the variable inside webpage.

     

    I want something opposite.

     

    Maybe there is possible to put return statement in function ExecuteScript() in a such way that it will return a value of global variable to the power automate

    And next I will just save this value to excel.

     

     

    Firstly, I was thinking to use "Get details of element on web page" or "Extract data from web page" but I am newbie with javascript and selectors and I don't know how I should to set the: "UI Element"(maybe somehow mark as whole document),  "Attribute name", or how I should fullfill "CSS Selector"

     

    With Web Dev Tools writing in console the names of global variables I can get the values. But this is manual solution and I need it to be done automatically by power automate.

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @SuperDragonfly 

    See if the below example helps you.

    For instance:

    I attempted to retrieve some inner text from the Power Automate Desktop community page, and it functioned correctly. Please review the code below or copy and paste it into your system to observe its functionality.

    Deenuji_0-1709571207358.png

     

     

    Code:

    WebAutomation.LaunchChrome.LaunchChrome Url: $'''https://powerusers.microsoft.com/t5/Power-Automate-Desktop/bd-p/MPADesktop''' WindowState: WebAutomation.BrowserWindowState.Maximized ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 PiPUserDataFolderMode: WebAutomation.PiPUserDataFolderModeEnum.AutomaticProfile BrowserInstance=> Browser
    WebAutomation.ExecuteJavascript BrowserInstance: Browser Javascript: $'''function ExecuteScript() {
    var Titleheader= document.querySelector(\"#lia-body > div.lia-page > div.MinimumWidthContainer > div > div > div > div.lia-quilt.lia-quilt-forum-page.lia-quilt-layout-two-column-main-side.lia-top-quilt > div.common_pageTitle > h1 > span\").innerText;
    return Titleheader;

    }''' Result=> Result

     

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 223

#2
David_MA Profile Picture

David_MA 195 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 167

Last 30 days Overall leaderboard