|
14 | 14 |
|
15 | 15 | import httpretty |
16 | 16 |
|
17 | | -from test.unit.helper.test_helper import android_w3c_driver, appium_command |
| 17 | +from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body |
18 | 18 |
|
19 | 19 |
|
20 | 20 | class TestWebDriverContext(object): |
| 21 | + @httpretty.activate |
| 22 | + def test_current_contexts(self): |
| 23 | + driver = android_w3c_driver() |
| 24 | + httpretty.register_uri( |
| 25 | + httpretty.GET, appium_command('/session/1234567890/context'), body='{"value": "NATIVE_APP"}' |
| 26 | + ) |
| 27 | + assert driver.current_context == 'NATIVE_APP' |
| 28 | + |
21 | 29 | @httpretty.activate |
22 | 30 | def test_get_contexts(self): |
23 | 31 | driver = android_w3c_driver() |
24 | | - httpretty.register_uri(httpretty.GET, appium_command('/session/1234567890/context'), body='{"value": "NATIVE"}') |
25 | | - assert driver.current_context == 'NATIVE' |
| 32 | + httpretty.register_uri( |
| 33 | + httpretty.GET, appium_command('/session/1234567890/contexts'), body='{"value": ["NATIVE_APP", "CHROMIUM"]}' |
| 34 | + ) |
| 35 | + |
| 36 | + assert ['NATIVE_APP', 'CHROMIUM'] == driver.contexts |
| 37 | + |
| 38 | + @httpretty.activate |
| 39 | + def test_switch_to_context(self): |
| 40 | + driver = android_w3c_driver() |
| 41 | + httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/context'), body='{"value": null}') |
| 42 | + |
| 43 | + driver.switch_to.context(None) |
| 44 | + |
| 45 | + assert {'name': None}, get_httpretty_request_body(httpretty.last_request()) |
| 46 | + |
| 47 | + @httpretty.activate |
| 48 | + def test_switch_to_context_native_app(self): |
| 49 | + driver = android_w3c_driver() |
| 50 | + httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/context'), body='{"value": null}') |
| 51 | + |
| 52 | + driver.switch_to.context('NATIVE_APP') |
| 53 | + |
| 54 | + assert {'name': 'NATIVE_APP'}, get_httpretty_request_body(httpretty.last_request()) |
0 commit comments