Back function is not working - Mobile-Elements-and-UIAutomator part 1 | Appium Forum
V
Vishal Jakkulwar Posted on 11/09/2020

Please can anyone advise on the issue below,

I am trying to use the "AndroidKey.Back" function but its not working as shown in video "Mobile-Elements-and-UIAutomator part 1".

Please note

  1. video shows the old version of the MakeMytrip appa from 2018. I am using 2020 version of the app and there is now a new search field on the top of the homepage.
  2. Also, if don't use the Back  option my code is successfully extracting the list of elements and geolocation. so it seems that the somehow back code is creating an issue

below is my code :

package identifyingelements2;

import java.util.List;
import org.junit.Test;


import Architecture.Base;
import io.appium.java_client.MobileBy;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;

public class CheckingActivity extends Base{

@Test
public void testIdentifyMkmt() throws InterruptedException {


startApp("C:\\Users\\Apk\\MakeMyTrip_com.makemytrip.apk");


Thread.sleep(8000);

List<AndroidElement> allElements = driver.findElements(MobileBy.AndroidUIAutomator("new UiSelector().resourceId(\"com.makemytrip:id/title\")"));
for(AndroidElement e :allElements) {
System.out.println(e.getText() + e.getLocation().x +","+e.getLocation().y);
e.click();
System.out.println(driver.currentActivity());
Thread.sleep(5000);
driver.pressKey(new KeyEvent(AndroidKey.BACK));
System.out.println("----------------------------------");
}

}
}

 

 

 

Outcome on the console:

Sep 10, 2020 8:15:16 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Try 'Delhi to Mumbai Flights'190,167
com.mmt.travel.app.homepage.universalsearch.ui.universalsearch.UniversalSearchActivity
----------------------------------

 

 

Also, attched the Appium log