Not able to switch between the driver for iOS devices

Hi,

I have created two drivers for the iOS devices. i was not able to switch between the devices.

Please find the sample code.

import os
import unittest
from appium import webdriver

Returns abs path relative to this file and not cwd

PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(file), p)
)

class iOSAudioCall(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps[‘port’] = ‘4733’
desired_caps[‘platformName’] = ‘iOS’
desired_caps[‘platformVersion’] = ‘9.4’
desired_caps[‘deviceName’] = ‘ios’
desired_caps[‘udid’] = ‘117cbc1f3fa0fe07cd1888b4753811ada8bb9460’#iphone 6plus
#desired_caps[‘udid’] = ‘807cf37f6c5dcca576373296e47e35a5e1390c37’
desired_caps[‘newCommandTimeout’] = ‘120’
desired_caps[‘server’] = ‘10.198.17.207’
desired_caps[‘appPackage’] = ‘com.xxx.xxxx’
desired_caps[‘appActivity’] = ‘com.xxx.xxxx.SplashScreenActivity’
desired_caps[‘component_type’] = ‘SMCiOSComponent’

    desired_caps1 = {}
    desired_caps1['port'] = '4734'
    desired_caps1['platformName'] = 'iOS'
    desired_caps1['platformVersion'] = '9.4'
    desired_caps1['deviceName'] = 'ios'
    desired_caps1['udid'] = '807cf37f6c5dcca576373296e47e35a5e1390c37'#iphone 6
    desired_caps1['newCommandTimeout'] = '120'
    desired_caps1['server'] = '10.198.17.207'
    desired_caps1['appPackage'] = 'com.xxx.xxxx'
    desired_caps1['appActivity'] = 'com.xxx.xxxx.SplashScreenActivity'
    desired_caps1['component_type'] = 'SMCiOSComponent'
    
    self.iosdriver = webdriver.Remote('http://10.198.17.207:4744/wd/hub', desired_caps1)
    self.driver = webdriver.Remote('http://10.198.17.207:4733/wd/hub', desired_caps)

def tearDown(self):
    self.driver.quit()

def testAudioCall(self):
    self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[2]/UIAButton[4]").click()
    self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[2]/UIAButton[14]").click()
    self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[2]/UIAButton[14]").click()
    self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[2]/UIAButton[12]").click()
    self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[2]/UIAButton[19]").click()
    
    self.iosdriver.find_element_by_name("Answer Audio").click()
    
    self.driver.find_element_by_name("End Call").click()

if name == ‘main’:
suite = unittest.TestLoader().loadTestsFromTestCase(iOSAudioCall)
unittest.TextTestRunner(verbosity=2).run(suite)