getText()used to retrieve visible innertText, you can use the method getAttributeto get the url (for hyperlink), something like below
String Actualtext = driver.findElement("YourElementLocator").getAttribute("href")
Assert.assertEquals(Actualtext, "http://localhost:8080/imdb/homepage" );
System.out.println("URL matching --> Part executed");
source
share