I have HTML page like this,
|
And the javascript is,
<
script language="javscript" type="text/javascript">
function goToRegister()
{
alert("Login Successful!");
window.location.href="Register.html";
}
</script>
In the selenium script,
@Test
public void goToRegisterPage()
{
System.out.println("goToRegisterPage");
WebDriverWait wait = new WebDriverWait(driver,10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.accept();
driver.get("file:///X://selenium//Register.html");
}
@BeforeMethod
public void beforeMethod()
{
System.out.println("beforeMethod called " + visitcount++);
System.setProperty("webdriver.gecko.driver", "X:\\Selenium\\geckodriver-v0.17.0-win32\\geckodriver.exe");
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("file:///X://selenium//Login.html");
}
Scenario:When I execute these scripts using TestNG Suite, I'm getting the Login page and script is passing the credentials to username and password and finally clicks on the Login button.
After clicked login button, javascript alert appears...then I'm getting again the login page instead of Register.html :(
Question: How to handle this scenario?
If anyone know answer for the above scenario, please post your comments here. Thanks
Comments