I have a task of which I am trying to accomplish using the Selenium libraries. The task is to check what the current URL is in the open browser, I don't mean a web browser, which has been opened by the web driver. I mean the current URL of whatever browser the user has open. Currently I am not completely sure whether this is possible, but I have a code which almost does it, but that is only if the browser has been opened using the web driver. Code seen below.
WebDriver driver = new ChromeDriver();
driver.get(“http://www.example.com”);
String currentUrl = driver.getCurrentUrl();
System.out.println(“The current URL is ” + currentUrl);
Thread.sleep(5000);
driver.quit();
Using that code I was wondering if it is possible to modify it, so that the driver element is the current one which the user has opened themselves and not the actual WebDriver?
So let's say the user has Chrome running on www.google.com, then the code would get the URL www.google.com as that is the current open URL in the Chrome browser.
Your driver is only able to communicate with its own range. What user is doing, Driver is not able to see that. Unless i have not understand your question correctly, what you are asking is an invalid question.