package me.alb_i986.selenium.tinafw.tasks;

import me.alb_i986.selenium.tinafw.pages.LoginPage;
import me.alb_i986.selenium.tinafw.pages.Page;
import me.alb_i986.selenium.tinafw.tasks.BaseWebTask;

public abstract class ImLoggedInBase extends BaseWebTask {

	/**
	 * Browse to the login page and do the login.
	 * 
	 * @param noPage this param won't be considered: may be null
	 */
	public Page run(Page noPage) {
		return
			user.getBrowser().browseTo(getLoginPageClass())
				.loginAs(user.getUsername(), user.getPassword())
			;
	}
	
	public abstract Class<? extends LoginPage> getLoginPageClass();

}

@@ -140,62 +140,141 @@
 ge;%0A
-import me.alb_i986.selenium.tinafw.tasks.BaseWebTask;%0A
+%0A/**%0A * Concrete subclasses must define the method %60getPageClassToLoad%60%0A * which needs to return a concrete %7B@link LoginPage%7D.%0A *%0A */
 %0Apub
@@ -315,20 +315,26 @@
 extends 
-Base
+Navigation
 WebTask 
@@ -460,16 +460,47 @@
 ll%0A%09 */%0A
+%09@SuppressWarnings(%22rawtypes%22)%0A
 %09public 
@@ -529,193 +529,142 @@
 %7B%0A%09%09
-return%0A%09%09%09user.getBrowser().browseTo(getLoginPageClass())%0A%09%09%09%09.loginAs(user.getUsername(), user.getPassword())%0A%09%09%09;%0A%09%7D%0A%09%0A%09public abstract Class%3C? extends LoginPage%3E getLoginPageClass();%0A
+Page loginPage = super.run(noPage);%0A%09%09return %0A%09%09%09((LoginPage) loginPage)%0A%09%09%09%09.loginAs(user.getUsername(), user.getPassword())%0A%09%09%09;%0A%09%7D%0A%09
 %0A%7D%0A

improve ImLoggedInBase