Scenario:
My baseUrl/Login
is something like this https://example.com/#/ and its opening in the 1st tab
. After entering the credentials, it is https://example.com/#/verification. I am navigating from here to another url which is opened in 2nd tab
. But when it backs to 1st tab
, It’s changing to the baseUrl
again.
public void visitMailinator() throws InterruptedException {
((JavascriptExecutor) driver).executeScript("window.open()");
ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
driver.switchTo().window(tabs.get(1));
Thread.sleep(10000);
driver.get(url);
Thread.sleep(4000);
first_mail.click();
Reporter.log("First mail is clicked ", true);
driver.switchTo().frame("html_msg_body");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
String verificationToken = token.getText();
Reporter.log("The Verification Token is: " + verificationToken, true);
Reporter.log("Browser is Navigating back", true);
Thread.sleep(6000);
driver.switchTo().window(tabs.get(0));
Reporter.log("Browser is Navigated back", true);
Thread.sleep(5000);
String link = driver.getCurrentUrl();
Reporter.log("current Link is: " + link, true);
driver.navigate().to("https://example/#/verification"); // Its not working
code_field.isDisplayed();
code_field.sendKeys(verificationToken);
Reporter.log("Verification Key is Entered", true);
}