"Page URL" Check

Hello,

is there a way to know if a "Page URL" is active/configured using expressions or scripts? I would need this to enable/disable commands based on whether the reference URL exists or not.

I found a solution that works for Perspective pages using "chromedriver" and "selenium".
Its a little bit tricky but it works.

While you provided a solution, it's not a good one. Use the 1st party provided functions to get the job done. system.perspective.getProjectInfo will provide a list of all page configurations for the project, which sounds like what you're looking for as it contains the configured mounted paths (project URLs).

3 Likes

Thank!! i’m going to try it!

1 Like

Ok! it works!

So for that function, it says it works from a Gateway scope but I'm getting this error in the logs calling that function from a timer script.

Caused by: java.lang.IllegalArgumentException: No perspective session attached to this thread.

Could you provide your code?

system.util.getLogger("ProjectInfo").info(str(system.perspective.getProjectInfo()))

Got it. The function returns information about the project being used by a Session. When executed by any non-Perspective context, the function has no idea what project to return data about.

I've reached out to the Documentation team to see about clarifying the docs.

1 Like

Gotcha. Thank you for updating the documentation team.

The Docs appear to be updated to reflect that Gateway is not a valid scope for this function.

1 Like

Dear team,

I have one doubt?
In Vision, to find out how long a particular window has been open, there's a 'System.gui.getWindow' function. Is there any similar function to determine how long a particular view has been open in perspective?

No, but it's not hard to implement by yourself using now(0).
But what exactly are you trying to do ?

I have 10 views in Perspective, and I need to get the value of which view the user opens and how long it has been open. I can use page.props.path in the onStartup script, but that would require doing it individually for each screen. I don't want to do it that way. I need to make it dynamic with one script so that I can know which screen the user is using and for how long.

Use a shared docked view. Put the check for page.props.path there.

Thank You! It works