|
14 | 14 |
|
15 | 15 | from selenium import webdriver
|
16 | 16 |
|
| 17 | +from .connectiontype import ConnectionType |
17 | 18 | from .mobilecommand import MobileCommand as Command
|
18 | 19 | from .errorhandler import MobileErrorHandler
|
19 | 20 | from .switch_to import MobileSwitchTo
|
@@ -569,6 +570,36 @@ def open_notifications(self):
|
569 | 570 | self.execute(Command.OPEN_NOTIFICATIONS, {})
|
570 | 571 | return self
|
571 | 572 |
|
| 573 | + @property |
| 574 | + def network_connection(self): |
| 575 | + """Returns an integer bitmask specifying the network connection type. |
| 576 | + Android only. |
| 577 | + Possible values are available through the enumeration `appium.webdriver.ConnectionType` |
| 578 | + """ |
| 579 | + return self.execute(Command.GET_NETWORK_CONNECTION, {})['value'] |
| 580 | + |
| 581 | + def set_network_connection(self, connectionType): |
| 582 | + """Sets the network connection type. Android only. |
| 583 | + Possible values: |
| 584 | + Value (Alias) | Data | Wifi | Airplane Mode |
| 585 | + ------------------------------------------------- |
| 586 | + 0 (None) | 0 | 0 | 0 |
| 587 | + 1 (Airplane Mode) | 0 | 0 | 1 |
| 588 | + 2 (Wifi only) | 0 | 1 | 0 |
| 589 | + 4 (Data only) | 1 | 0 | 0 |
| 590 | + 6 (All network on) | 1 | 1 | 0 |
| 591 | + These are available through the enumeration `appium.webdriver.ConnectionType` |
| 592 | +
|
| 593 | + :Args: |
| 594 | + - connectionType - a member of the enum appium.webdriver.ConnectionType |
| 595 | + """ |
| 596 | + data = { |
| 597 | + 'parameters': { |
| 598 | + 'type': connectionType.value |
| 599 | + } |
| 600 | + } |
| 601 | + return self.execute(Command.SET_NETWORK_CONNECTION, data)['value'] |
| 602 | + |
572 | 603 | def _addCommands(self):
|
573 | 604 | self.command_executor._commands[Command.CONTEXTS] = \
|
574 | 605 | ('GET', '/session/$sessionId/contexts')
|
@@ -625,6 +656,10 @@ def _addCommands(self):
|
625 | 656 | ('POST', '/session/$sessionId/appium/device/hide_keyboard')
|
626 | 657 | self.command_executor._commands[Command.OPEN_NOTIFICATIONS] = \
|
627 | 658 | ('POST', '/session/$sessionId/appium/device/open_notifications')
|
| 659 | + self.command_executor._commands[Command.GET_NETWORK_CONNECTION] = \ |
| 660 | + ('GET', '/session/$sessionId/network_connection') |
| 661 | + self.command_executor._commands[Command.SET_NETWORK_CONNECTION] = \ |
| 662 | + ('POST', '/session/$sessionId/network_connection') |
628 | 663 |
|
629 | 664 |
|
630 | 665 | # monkeypatched method for WebElement
|
|
0 commit comments