Łukasz Błaszkiewicz
Łukasz Błaszkiewicz

Reputation: 13

Selenium, Python - How to switch back from one native app to another

I have the mobile application where to login I have to provide my phone number and then I get the sms code for a login confirmation. I can easily open the Messages in android using driver.start_activity('','') and get the sms code but I am not able to switch back to the application because when I use driver.start_activity('','') the application starts from splash screen and I lose the place to input the sms code

What I have until now:

driver.start_activity('com.google.android.apps.messaging', 'com.google.android.apps.messaging.ui.ConversationListActivity')

driver.find_element_by_xpath("//android.support.v7.widget.RecyclerView[@content-desc='Lista wątków']/android.view.ViewGroup[1]").click()

messages = driver.find_elements_by_id('com.google.android.apps.messaging:id/message_text')
text = messages[len(messages) - 1].text
smsCode = print(text[19:26])````

How am I supposed to switch back to the app and not lose all the content?
I'm using Appium, Selenium, Python

Upvotes: 1

Views: 171

Answers (0)

Related Questions