public class HyperLinkTest {
@Test
void redirector(){
WebDriver driver = new ChromeDriver();
driver.get("https://the-internet.herokuapp.com/redirector");
driver.findElement(By.linkText("here")).click();// <----
Assert.assertEquals(driver.getCurrentUrl(),"https://the-internet.herokuapp.com/status_codes");
driver.findElement(By.linkText("200")).click();
Assert.assertEquals(driver.getCurrentUrl(),"https://the-internet.herokuapp.com/status_codes/200");
String content = driver.findElement(By.id("content")).getText();
Assert.assertTrue(content.contains("This page returned a 200 status code."));
driver.findElement(By.linkText("here")).click();
driver.findElement(By.linkText("301")).click();
Assert.assertEquals(driver.getCurrentUrl(),"https://the-internet.herokuapp.com/status_codes/301");
driver.findElement(By.linkText("here")).click();
driver.findElement(By.linkText("404")).click();
Assert.assertEquals(driver.getCurrentUrl(),"https://the-internet.herokuapp.com/status_codes/404");
driver.findElement(By.linkText("here")).click();
driver.findElement(By.linkText("500")).click();
Assert.assertEquals(driver.getCurrentUrl(),"https://the-internet.herokuapp.com/status_codes/500");
driver.findElement(By.linkText("here")).click();
driver.quit();
}
}