Get the address bar url from a browser

Jul 8, 2021 at 10:14am
I would like to know how can I get the url from the address bar in a browser, I would like to do it preferably in the most popular browsers like firefox, chrome, edge, opera etc.

The code from this snswer from stack overflow answer https://stackoverflow.com/a/19296923/11337328 does what I want but only works for Internet Explorer, I don't understand the code, how it is getting that info though.

If someone knows how can I do that for other browsers please help. Thank you.
Jul 8, 2021 at 12:16pm
Is this a Windows specific question? If so, please move it to the Windows Programming section.
Jul 8, 2021 at 12:39pm
It goes both to windows and linux. But I will post it on indows Programming section to see if I get the answer for the windows side.
Jul 8, 2021 at 1:11pm
https://www.selenium.dev/documentation/en/webdriver/
Good news - it supports all browsers and is cross-platform.
Bad news - it doesn't have a C++ binding (or maybe it does https://github.com/durdyev/webdriverxx )
Last edited on Jul 8, 2021 at 1:11pm
Jul 8, 2021 at 1:15pm
Jul 8, 2021 at 1:18pm
That code finds the windows according to their name and the structure (i.e. what wndow has what child).

So if you knew the names and structure of the windows of firefox etc. you could do the same for them.
Jul 8, 2021 at 1:34pm
most browsers have some sort of plugin interface and there should be a way to tap the data you need from it: that seems like a very basic piece of info.

trying to back-hack the gui to steal a piece of info is difficult and aggravating; it is a last resort that is bug prone (updates to the browser can break your code) and can even trigger some anti virus etc.
Jul 8, 2021 at 4:12pm
@salem c
The webdriverxx always throws an expcetion( what() : Cannot perform HTTP request (result: 7, message: Failed to connect to localhost port 4444: Connection refused )
And still, by looking at some of its code examples I couldn't understand how that would help on my problem.
Jul 8, 2021 at 4:14pm
@coder777 Any idea on how I would get those names. I tried Spy++ but could figure out how it works.
Jul 8, 2021 at 9:13pm
Topic archived. No new replies allowed.