How to switch from one Activity to another Activity within the application?
@Note: I am using TESTNG framework.
Below is my code.
String settingsAppPackageName="com.xxx.xxx.xxxx.dashBoard";
String settingsAppActivityName="com.xxxx.xxxx.xxx.xxx.DashBoard";
@Test(priority = 1)
public void loginTC2(){
System.out.println("Login 3333::>"+driver.currentActivity());
if(driver.currentActivity().equals("com.xxx.xxx.xxxx.login.LoginActivity")){
System.out.println("Login 6666::>"+driver.currentActivity());
driver.findElement(By.id("com.xxxx.xxxx.xxxx:id/edtUserName")).sendKeys("xxxx");
driver.findElement(By.id("com.xxxx.xxxx.xxxx:id/edtPassword")).sendKeys("xxxx");
driver.findElement(By.id("com.xxxx.xxxx.xxxx:id/btnLogin")).click();
// If action is executed then I want to navigate to DashboardActivity
driver.startActivity(settingsAppPackageName, settingsAppActivityName);
}else{
System.out.println("Login 4444::>"+driver.currentActivity());
}
}