Login.java file:
public class LoginPage
{
@Test
public void loginAs() throws Exception {
String baseUrl = "";
String uname = "";
String pwd = "";
driver = new FirefoxDriver();
driver.get(baseUrl);
String url = "";
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id=\"login-form\"]/tbody/tr[2]/td/div[1]/input")).sendKeys(uname);
driver.findElement(By.xpath("//*[@id=\"login-form\"]/tbody/tr[2]/td/div[2]/input")).sendKeys(pwd);
driver.findElement(By.id("login")).click();
String currentUrl = driver.getCurrentUrl();
if(currentUrl.equals(url)) {
System.out.println("Login Success");
}
else {
System.out.println("Login Fail");
}
driver.navigate().to("");
}
}
CreateTask.java file:
public class CreateTask {
WebDriver driver;
@After
public void tearDown() throws Exception {
}
@Test
public void addTask() {
driver.findElement(By.xpath("//*[@id=\"my-workspace-box\"]/ul/li[1]/a[1]")).click();
}
}
MainMethod.java File
public class firefoxDemo {
public static void main(String[] args) {
//System.setProperty("webdriver.gecko.driver", "C:\\Users\\praviprakash\\Desktop\\geckodriver-v0.18.0-win64.exe");
LoginPage login = new LoginPage();
CreateTask task = new CreateTask();
try {
login.loginAs();
task.addTask();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Above is the code. Application is not running after the login functionality. How should i link so that it will run continously?