Hi ,
This is regarding the Object Casting in Page Object Model Framework.
Please find the below code.
[i:1du5ez0g]
Object page=loginPage.doLogin("kannan789@gmail.com", "password1980");
if (page instanceof LandingPage)
[b:1du5ez0g]LandingPage landingPage[/b:1du5ez0g]=(LandingPage) page;
else if (page instanceof LoginPage)
Assert.fail("Login Failed");
MyAccountPage myAccountPage=landingPage.clickonMyaccount()[/i:1du5ez0g]
When try the above code getting an error "LandingPage cannot be resolved to a variable"
But if I added {} for the if statement then the error message goes off
if (page instanceof LandingPage)
{
LandingPage landingPage=(LandingPage) page;
}
But in both the time the code MyAccountPage myAccountPage=landingPage.clickonMyaccount() shows the error message "landingPage cannot be resolved"
Kindly clarify this.