Activates the application if it is not running or is running in the background. Args: app_id: the application id to be activated Returns: Union['WebDriver', 'Applications']: Self instance
(self, app_id: str)
| 173 | return self.mark_extension_absence(ext_name).execute(Command.TERMINATE_APP, data)['value'] |
| 174 | |
| 175 | def activate_app(self, app_id: str) -> Self: |
| 176 | """Activates the application if it is not running |
| 177 | or is running in the background. |
| 178 | |
| 179 | Args: |
| 180 | app_id: the application id to be activated |
| 181 | |
| 182 | Returns: |
| 183 | Union['WebDriver', 'Applications']: Self instance |
| 184 | """ |
| 185 | ext_name = 'mobile: activateApp' |
| 186 | try: |
| 187 | self.assert_extension_exists(ext_name).execute_script( |
| 188 | ext_name, |
| 189 | { |
| 190 | 'appId': app_id, |
| 191 | 'bundleId': app_id, |
| 192 | }, |
| 193 | ) |
| 194 | except (UnknownMethodException, InvalidArgumentException): |
| 195 | # TODO: Remove the fallback |
| 196 | self.mark_extension_absence(ext_name).execute(Command.ACTIVATE_APP, {'appId': app_id}) |
| 197 | return self |
| 198 | |
| 199 | def query_app_state(self, app_id: str) -> int: |
| 200 | """Queries the state of the application. |