test_session.py (1666B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 from marionette_driver import errors 6 7 from marionette_harness import MarionetteTestCase 8 9 10 class TestSession(MarionetteTestCase): 11 def setUp(self): 12 super(TestSession, self).setUp() 13 14 self.marionette.delete_session() 15 16 def test_new_session_returns_capabilities(self): 17 # Sends newSession 18 caps = self.marionette.start_session() 19 20 # Check that session was created. This implies the server 21 # sent us the sessionId and status fields. 22 self.assertIsNotNone(self.marionette.session) 23 24 # Required capabilities mandated by WebDriver spec 25 self.assertIn("browserName", caps) 26 self.assertIn("browserVersion", caps) 27 self.assertIn("platformName", caps) 28 29 def test_get_session_id(self): 30 # Sends newSession 31 self.marionette.start_session() 32 33 self.assertTrue(self.marionette.session_id is not None) 34 self.assertTrue(isinstance(self.marionette.session_id, str)) 35 36 def test_session_already_started(self): 37 self.marionette.start_session() 38 self.assertTrue(isinstance(self.marionette.session_id, str)) 39 with self.assertRaises(errors.SessionNotCreatedException): 40 self.marionette._send_message("WebDriver:NewSession", {}) 41 42 def test_no_session(self): 43 with self.assertRaises(errors.InvalidSessionIdException): 44 self.marionette.get_url() 45 46 self.marionette.start_session() 47 self.marionette.get_url()