Mobile Automation - Not able to get 'URL' of the browser's current page

Hi Team,
I’m working on automating an mobile web application in UiPath MDM. I have connected using browser stack for this. Here i need to get the URL of the current browser page, seems like there is no activity for Mobile Automation to get the URL of the browser in MDM. Anyone who has experienced this issue and can suggest how to resolve this ? Thanks

Best Regards,
Kamal

You can use Appium APIs to get the current url. See Mobile Automation - Not able to go 'Back' in browser - #8 by phaserescu for an example on how to use the APIs.

The endpoint is

GET [appiumUrl]/session/[session_id]/url

Hi @phaserescu, I tried using the method you suggested “GET [appiumUrl]/session/[session_id]/url” but faced with the below error message for the ‘Output Response Content’
The image displays a JSON error message indicating a "405" status and stating "Method has not yet been implemented," with certain parts redacted. (Captioned by AI)

I think this is because you’re in a hybrid context, and you have to explicitly set a web context.

Here is an example for get page source which has the same requirements.

project.zip (3.6 KB)

The workflow does the following:

  1. Get the session identifier
  2. Sets the authorization details (sauceLabsUsername and sauceLabsKey)
  3. Constructs the API url
  4. Makes a GET request to save the contexts (but it doesn’t use it because this is just a POC … normally you want to parse those and see if CHROMIUM is in there or sometimes explicit WEBVIEW.* contexts are in there)
  5. Sets the context to CHROMIUM
  6. Invokes Get Page Source to get the page source - instead of this you call the api for get url

Hi @phaserescu, i used the ‘Get Page’ source activity to get the page’s source and got the page URL from that. But here the issue is that it is difficult to get specified URL as the text file contains all the page source.

Can you explain on explicitly set a web context, so that i can use API to get URL of the page?

To get the available contexts you have the following API

GET [appiumUrl]/session/[session_id]/contexts

To get the current context

GET [appiumUrl]/session/[session_id]/context

Just for testing you can skip the parsing context part. Just see if you have CHROMIUM in the list of contexts (if you’re on Android, this is probably true). If not, look in the list for contexts starting with WebView.

And to set the context

POST [appiumUrl]/session/[session_id]/context

{"name": "CHROMIUM"}