OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Tests for ChromeDriver. | 5 """Tests for ChromeDriver. |
6 | 6 |
7 If your test is testing a specific part of the WebDriver API, consider adding | 7 If your test is testing a specific part of the WebDriver API, consider adding |
8 it to the appropriate place in the WebDriver tree instead. | 8 it to the appropriate place in the WebDriver tree instead. |
9 """ | 9 """ |
10 | 10 |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 self.assertRaises(NoSuchWindowException, self._driver.get_window_position, | 1029 self.assertRaises(NoSuchWindowException, self._driver.get_window_position, |
1030 invalid_handle) | 1030 invalid_handle) |
1031 | 1031 |
1032 | 1032 |
1033 class GeolocationTest(ChromeDriverTest): | 1033 class GeolocationTest(ChromeDriverTest): |
1034 """Tests for WebDriver geolocation commands.""" | 1034 """Tests for WebDriver geolocation commands.""" |
1035 | 1035 |
1036 def testGeolocation(self): | 1036 def testGeolocation(self): |
1037 """Tests the get and set geolocation commands.""" | 1037 """Tests the get and set geolocation commands.""" |
1038 driver = self.GetNewDriver() | 1038 driver = self.GetNewDriver() |
| 1039 driver.get(self.GetTestDataUrl() + '/empty.html') |
1039 | 1040 |
1040 # TODO(kkania): Update the python bindings and get rid of these. | 1041 # TODO(kkania): Update the python bindings and get rid of these. |
1041 driver.command_executor._commands.update({ | 1042 driver.command_executor._commands.update({ |
1042 'getLoc': ('GET', '/session/$sessionId/location'), | 1043 'getLoc': ('GET', '/session/$sessionId/location'), |
1043 'setLoc': ('POST', '/session/$sessionId/location') | 1044 'setLoc': ('POST', '/session/$sessionId/location') |
1044 }) | 1045 }) |
1045 def getLocation(): | 1046 def getLocation(): |
1046 return driver.execute('getLoc')['value'] | 1047 return driver.execute('getLoc')['value'] |
1047 def setLocation(location): | 1048 def setLocation(location): |
1048 driver.execute('setLoc', {'location': location}) | 1049 driver.execute('setLoc', {'location': location}) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 | 1202 |
1202 def testMediaStream(self): | 1203 def testMediaStream(self): |
1203 driver = self.GetNewDriver() | 1204 driver = self.GetNewDriver() |
1204 # Allowing camera/mic access by default only works for https sites. | 1205 # Allowing camera/mic access by default only works for https sites. |
1205 driver.get(self.GetHttpsTestDataUrl() + '/empty.html') | 1206 driver.get(self.GetHttpsTestDataUrl() + '/empty.html') |
1206 driver.set_script_timeout(10) | 1207 driver.set_script_timeout(10) |
1207 # Will timeout if infobar appears. | 1208 # Will timeout if infobar appears. |
1208 driver.execute_async_script( | 1209 driver.execute_async_script( |
1209 'navigator.webkitGetUserMedia({audio:true, video:true},' + | 1210 'navigator.webkitGetUserMedia({audio:true, video:true},' + |
1210 ' arguments[0], arguments[0]);') | 1211 ' arguments[0], arguments[0]);') |
OLD | NEW |