I have written a Java code with if-else statements and user would move from 'Screen1' to 'Screen2' through any of 4 alternate routes and I have attached an image for all
possible application flows which are decided on the go by of course code written by developer. Just to add tool used is Appium.
driver.findElement(By.id("----")).click(); //this click will take from 'screen1' to next screen.
if(driver.findElement(By.id("com.abc.rbanking:id/WhatsNew")).isDisplayed())
{ //case if screen A is displayed just after screen 1
MobileElement cross = driver.findElement(By.xpath("//*[@class = 'android.widget.ImageView']"));
cross.click();
Thread.sleep(3000);
}
if(driver.findElement(By.xpath("//android.widget.TextView[@resource-id='com.abc.rbanking:id/text_logo'][text()='Security Question']")).isDisplayed())
{ //case when screen B is displayed Just after screen 1
MobileElement mfaQ = driver.findElement(By.id("com.abc.rbanking:id/MfaQuestionText"));
String question = mfaQ.getText();
String lastword = question.replaceAll("^.*?(\\w+)\\W*$", "$1");
System.out.println(lastword);
MobileElement answer = driver.findElement(By.id("com.abc.rbanking:id/MfaAnswerTextBox"));
answer.sendKeys(lastword);
MobileElement checkbox = driver.findElement(By.id("com.abc.rbanking:id/ShowChallengeAnswerCheckbox"));
checkbox.click();
Thread.sleep(3000);
MobileElement nextb = driver.findElement(By.id("com.abc.rbanking:id/PrimaryButton"));
nextb.click();
Thread.sleep(8000);
}
if(driver.findElement(By.id("com.abc.rbanking:id/WhatsNew")).isDisplayed())
{ //case when screen A is displayed after screen B
MobileElement cross = driver.findElement(By.xpath("//*[@class = 'android.widget.ImageView']"));
cross.click();
Thread.sleep(3000);
}
driver.findElement(By.id("----")); //this is code for 'Screen 2'
What happens is during execution of script, first 'If' is checked and rest all code skipped. I am not able to figure out the issue. Please help.