In Appium (using Python) I want to send the app to the background, do some work while the app is in background (that would send a push notification to the app), and then return to the app.
I tried to do it with threads (threading.Thread
Python class), but it wouldn't do it in parallel - the app would sit in background, and after that was done, the second thread would start.
Then I tried it with multiprocessing.Process
, but I'm getting AttributeError: Can't pickle local object 'PoolManager.__init__.<locals>.<lambda>'
How should I go about this?
These are the parts of the code I have now (as I understand, the functions that should be parallelized need to be outside of the class):
def send_app_to_background(app_driver, seconds=10):
app_driver.background_app(seconds)
def asdf_verify_user(page:OnboardingPage, passenger_email):
mailer = MyMailer(passenger_email, page.settings)
verification_url = mailer.get_verification_url()
page.open_verification_url(verification_url)
And this is how it's called from inside the test class:
class TestMails(kh.BasicTest):
def test_registration_mails(self):
........
jobs = []
process1 = Process(target=send_app_to_background, args=(self.app_driver, 20))
process2 = Process(target=verify_user, args=(page, passenger_email))
jobs.append(process1)
jobs.append(process2)
for j in jobs:
j.start()
for j in jobs:
j.join()