Need to change the orientation of app which is dependent on sensor
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 1.8k
- Forks
- 570
- Merge moyen
- 1 j 10 h
- PR mergées (30 j)
- 24
Description
The problem
I have a mobile app which opens in portrait mode and later I need to switch to landscape mode. I have tried all possible solutions but the app does not turn to landscape mode but if I minimize the app , my emulator screen is changed to landscape. My app rotation is dependent on the sensor. How can I handle this using appium with python. I am using Appium-Python-Client 4.0.0.
Environment
- Appium version (or git revision) that exhibits the issue: v1.22.3
- Last Appium version that did not exhibit the issue (if applicable):
- Desktop OS/version used to run Appium: Windows 11
- Node.js version (unless using Appium.app|exe):
- Mobile platform/version under test: Android
- Real device or emulator/simulator: Emulator
- Appium CLI or Appium.app|exe: Appium CLI
Link to Appium Logs
[HTTP] <-- POST /wd/hub/session 200 8341 ms - 1017
[HTTP]
[HTTP] --> GET /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation
[HTTP] {}
[W3C (532110c9)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation' to command name 'getOrientation'
[debug] [WD Proxy] Proxying [GET /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation] to [GET http://127.0.0.1:8203/wd/hub/session/cf21f8fe-7a33-44b8-94ad-1b8b62efc047/orientation] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"cf21f8fe-7a33-44b8-94ad-1b8b62efc047","value":"PORTRAIT"}
[WD Proxy] Replacing sessionId cf21f8fe-7a33-44b8-94ad-1b8b62efc047 with 532110c9-f52f-408a-b2a7-b0a476e3b315
[HTTP] <-- GET /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation 200 1378 ms - 71
[HTTP]
[HTTP] --> GET /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation
[HTTP] {}
[W3C (532110c9)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation' to command name 'getOrientation'
[debug] [WD Proxy] Proxying [GET /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation] to [GET http://127.0.0.1:8203/wd/hub/session/cf21f8fe-7a33-44b8-94ad-1b8b62efc047/orientation] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"cf21f8fe-7a33-44b8-94ad-1b8b62efc047","value":"PORTRAIT"}
[WD Proxy] Replacing sessionId cf21f8fe-7a33-44b8-94ad-1b8b62efc047 with 532110c9-f52f-408a-b2a7-b0a476e3b315
[HTTP] <-- GET /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation 200 19 ms - 71
[HTTP]
[HTTP] --> POST /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation
[HTTP] {"orientation":"LANDSCAPE"}
[W3C (532110c9)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation' to command name 'setOrientation'
[debug] [WD Proxy] Proxying [POST /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation] to [POST http://127.0.0.1:8203/wd/hub/session/cf21f8fe-7a33-44b8-94ad-1b8b62efc047/orientation] with body: {"orientation":"LANDSCAPE"}
[WD Proxy] Got response with status 400: {"sessionId":"cf21f8fe-7a33-44b8-94ad-1b8b62efc047","value":{"error":"invalid element state","message":"Screen rotation cannot be changed to ROTATION_270 after 2000ms. Is it locked programmatically?","stacktrace":"io.appium.uiautomator2.common.exceptions.InvalidElementStateException: Screen rotation cannot be changed to ROTATION_270 after 2000ms. Is it locked programmatically?\n\tat io.appium.uiautomator2.model.internal.CustomUiDevice.setRotationSync(CustomUiDevice.java:184)\n\tat io.appium.uiautomator2.handler.SetOrientation.safeHandle(SetOrientation.java:41)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:266)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:260)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandle...
[debug] [W3C] Matched W3C error code 'invalid element state' to InvalidElementStateError
[HTTP] <-- POST /wd/hub/session/532110c9-f52f-408a-b2a7-b0a476e3b315/orientation 400 2068 ms - 3926
Code To reproduce issue
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’endpoint d’orientation de Appium-Python-Client indiqué dans les logs, en particulier la requête POST qui définit LANDSCAPE et l’erreur du driver Android. Reproduisez le comportement sur l’émulateur Android et avec les versions d’Appium indiqués, puis déterminez si l’échec relève du client ou du driver sous-jacent. Le travail est terminé lorsqu’un périmètre clair et reproductible ainsi que le comportement d’orientation attendu ont été identifiés.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- mobile, testing-qa
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 20/100