File tree Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 16
16
class MobileCommand (object ):
17
17
# Common
18
18
GET_SESSION = 'getSession'
19
+ GET_ALL_SESSIONS = 'getAllSessions'
19
20
20
21
GET_LOCATION = 'getLocation'
21
22
SET_LOCATION = 'setLocation'
Original file line number Diff line number Diff line change @@ -701,6 +701,16 @@ def session(self):
701
701
"""
702
702
return self .execute (Command .GET_SESSION )['value' ]
703
703
704
+ @property
705
+ def all_sessions (self ):
706
+ """ Retrieves all sessions that are open
707
+ Usage:
708
+ sessions = driver.allSessions
709
+ Returns:
710
+ `dict containing all open sessions`
711
+ """
712
+ return self .execute (Command .GET_ALL_SESSIONS )['value' ]
713
+
704
714
@property
705
715
def events (self ):
706
716
""" Retrieves events information from the current session
Original file line number Diff line number Diff line change @@ -24,10 +24,21 @@ class WebDriverTests(unittest.TestCase):
24
24
def setUp (self ):
25
25
desired_caps = desired_capabilities .get_desired_capabilities ('UICatalog.app.zip' )
26
26
self .driver = webdriver .Remote ('http://localhost:4723/wd/hub' , desired_caps )
27
+ desired_caps ['deviceName' ] = 'iPhone Xs Max'
28
+ desired_caps ['wdaLocalPort' ] = '8102'
27
29
28
30
def tearDown (self ):
29
31
self .driver .quit ()
30
32
33
+ def testAllSessions (self ):
34
+ desired_caps = desired_capabilities .get_desired_capabilities ('UICatalog.app.zip' )
35
+ desired_caps ['deviceName' ] = 'iPhone Xs Max'
36
+ desired_caps ['wdaLocalPort' ] = '8102'
37
+ self .driver1 = webdriver .Remote ('http://localhost:4723/wd/hub' , desired_caps )
38
+ self .assertEqual (2 , len (self .driver .all_sessions ))
39
+ if self .driver1 :
40
+ self .driver1 .quit ()
41
+
31
42
def test_app_management (self ):
32
43
# this only works in Xcode9+
33
44
if float (desired_capabilities .get_desired_capabilities (
Original file line number Diff line number Diff line change @@ -257,6 +257,17 @@ def test_create_session_register_uridirect_no_direct_connect_path(self):
257
257
assert 'http://localhost:4723/wd/hub' == driver .command_executor ._url
258
258
assert ['NATIVE_APP' , 'CHROMIUM' ] == driver .contexts
259
259
260
+ @httpretty .activate
261
+ def test_get_all_sessions (self ):
262
+ driver = ios_w3c_driver ()
263
+ httpretty .register_uri (
264
+ httpretty .GET ,
265
+ appium_command ('/sessions' ),
266
+ body = json .dumps ({'value' : {'deviceName' : 'iPhone Simulator' , 'events' : {'simStarted' : [1234567891 ]}}})
267
+ )
268
+ session = driver .all_sessions
269
+ assert len (session ) != 1
270
+
260
271
@httpretty .activate
261
272
def test_get_session (self ):
262
273
driver = ios_w3c_driver ()
You can’t perform that action at this time.
0 commit comments