0

I'm automating an Android App using Appium. The issue I'm facing is it doesn't perform any action after tabbing on allow button of Contact Access Permission as shown in below Image :

enter image description here

I've tried below code for the same :

@Test
public void doLogin()
{

    driver.findElement(By.id("com.rawalinfocom.rcontact:id/text_next")).click();
    // Clicks on Allow Button
    driver.findElement(By.id("com.android.packageinstaller:id/permission_allow_button")).click();
    // Clicks on Skip link
    driver.findElement(By.id("com.rawalinfocom.rcontact:id/text_skip")).click();
    driver.findElement(By.id("com.rawalinfocom.rcontact:id/checkbox_terms_conditions")).click();
    driver.findElement(By.id("com.rawalinfocom.rcontact:id/button_get_started")).click();
    driver.findElement(By.id("com.rawalinfocom.rcontact:id/input_number")).sendKeys("9422307801");
    driver.findElement(By.id("com.rawalinfocom.rcontact:id/button_submit")).click();
    driver.findElement(By.id("com.rawalinfocom.rcontact:id/input_enter_password")).sendKeys("1234");
    driver.findElement(By.id("com.rawalinfocom.rcontact:id/button_login")).click();
    System.out.print("Login Success");
}

I'm newbie in Appium. How can I find the missing thing?

halfer
  • 19,824
  • 17
  • 99
  • 186
NarendraR
  • 7,577
  • 10
  • 44
  • 82

3 Answers3

0

In when pop ups like this comes the focus of driver is switched to that popup and is never returned after clicking, in such cases what you can do is keep "driver.getPageSource()" line right after clicking on that pop up and if it does not work in order to return the driver focus you can tap at some random location which will return the driver focus back to app

In order to tap at random position it will safe to tap at top position like (0,0) or (width/2,10) like that.

i tried tapping in one of the similar situation and it worked.

Jyothi
  • 28
  • 3
0

I'm able to handle the popup by setting up below capabilities :

capabilities.setCapability("autoGrantPermissions", "true");
capabilities.setCapability("autoAcceptAlerts", "true");

In this case it doesn't show the popup the permission set always granted.

NarendraR
  • 7,577
  • 10
  • 44
  • 82
0

Try using TouchAction class for tapping instead of click method. E.g.:

MobileElement skip = driver.findElement(By.id("com.rawalinfocom.rcontact:id/text_skip"));
TouchAction touch = new TouchAction (driver);
touch.tap (skip).perform ();

Also, I am assuming that you have used driver as AndroidDriver as illustrated below:

AndroidDriver <MobileElement> driver = new AndroidDriver (new URL ("http://<appium IP>:<Port>/wd/hub"), capabilities);

Hopefully this should work as it's working for me too.

Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12
  • So it seems you might be using an older version of Appium and it's Java bindings, 'coz this same case works for me. If you can try with latest 5.0.4 version of Java bindings with 1.7.1 Appium and let me know? – Wasiq Bhamla Nov 23 '17 at 11:07
  • I have the version what you have mentioned. but unfortunately it doesn't seems to work for me. I found the alternative and already posted. thanks – NarendraR Nov 23 '17 at 12:02