# How to achieve clean state before Google + login scenario?

**URL:** <https://discuss.appium.io/t/how-to-achieve-clean-state-before-google-login-scenario/10633>\
**Category:** Feature\
**Created:** [June 9, 2016, 6:50am UTC](https://discuss.appium.io/t/how-to-achieve-clean-state-before-google-login-scenario/10633 "2016-06-09T06:50:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiedysktos](https://discuss.appium.io/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@kiedysktos](https://discuss.appium.io/u/kiedysktos)\
**Post date:** [June 9, 2016, 6:50am UTC](https://discuss.appium.io/t/how-to-achieve-clean-state-before-google-login-scenario/10633/1 "2016-06-09T06:50:01Z")

</div>

Hi,

I’d like to automate login with Google + scenario on Android.

I develop the tests on my business phone where I use a few Google accounts, so when I click “Login with G+” button in mobile app I see a list of accounts to pick from. I can remove those accounts if needed, but then after test scenario account will be there in again.

If I’ll run the tests on some simulator or clean device the screen will be different - login and password at first time.

So the question is: can I automatically remove all G+ accounts **from Android device settings** before/after test using Appium?  
Or I should take some other approach? Any advices are welcome!

Kamil

---

<div class="post-metadata">

**Author:** ![Chirag\_Singh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@Chirag\_Singh](https://discuss.appium.io/u/Chirag_Singh)\
**Post date:** [June 9, 2016, 9:14am UTC](https://discuss.appium.io/t/how-to-achieve-clean-state-before-google-login-scenario/10633/2 "2016-06-09T09:14:12Z")

</div>

You can clear the app data by using below adb command through java code:

**adb shell pm clear** _packageName_

where packageName is G+ App package.

---

<div class="post-metadata">

**Author:** ![kiedysktos](https://discuss.appium.io/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@kiedysktos](https://discuss.appium.io/u/kiedysktos)\
**Post date:** [June 9, 2016, 9:36am UTC](https://discuss.appium.io/t/how-to-achieve-clean-state-before-google-login-scenario/10633/3 "2016-06-09T09:36:23Z")

</div>

Thanks for reply! Unfortunately the Google accounts are something general to the device (Settings/Accounts), it’s not stored only in the cash of single app. Is there any command that removes all accounts from settings?

**EDIT: I’ve found following for rooted devices:**  
**adb shell rm -r /data/system/accounts.db**

Not tested it yet.

---

<div class="post-metadata">

**Author:** ![Ankit\_Kumar](https://discuss.appium.io/user_avatar/discuss.appium.io/ankit_kumar/32/9223_2.png) [@Ankit\_Kumar](https://discuss.appium.io/u/Ankit_Kumar)\
**Post date:** [September 27, 2021, 6:51am UTC](https://discuss.appium.io/t/how-to-achieve-clean-state-before-google-login-scenario/10633/4 "2021-09-27T06:51:57Z")

</div>

I don’t have the exact answer but you can try this work around

```auto
List<WebElement> acc_picker= driver.findElements(By.xpath("//android.widget.ListView[contains(@resource-id,'list')]/android.widget.LinearLayout")).subList(0, 2);
for(WebElement cc:acc_picker)
        {
            String email=cc.findElement(By.xpath("//android.widget.LinearLayout")).findElement(By.xpath("//android.widget.TextView[@index ='1']")).getText();
}

```

Get all the account name and choose yours. Hope it helps!
