Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appium crashes on reset if current context is webview #12083

Closed
xlenz opened this issue Jan 25, 2019 · 9 comments · May be fixed by EdtechFoundry/appium#13 or EdtechFoundry/appium#30
Closed

Appium crashes on reset if current context is webview #12083

xlenz opened this issue Jan 25, 2019 · 9 comments · May be fixed by EdtechFoundry/appium#13 or EdtechFoundry/appium#30
Assignees
Labels
Android related to Android-native driver(s) Bug a problem that needs fixing Mobile Chrome related to mobile Chrome driver

Comments

@xlenz
Copy link

xlenz commented Jan 25, 2019

The problem

Appium crashes on reset if current context is webview

Environment

  • Appium version (or git revision) that exhibits the issue: 1.10.1
  • Desktop OS/version used to run Appium: MacOS
  • Node.js version (unless using Appium.app|exe): 10
  • Npm or Yarn package manager: 6.7.0
  • Mobile platform/version under test: Android 9
  • Real device or emulator/simulator: real
  • Appium CLI or Appium.app|exe: appium from npm

Details

Appium crashes on reset if current context is webview

Link to Appium logs

https://gist.github.com/xlenz/d6fb0d779e8735784a8af4e6148f6342

Code To Reproduce Issue [ Good To Have ]

code won't be helpful, here is highlevel steps:

  1. run tests for some app
  2. do something in native context
  3. switch to webview
  4. do reset
  5. switch to native context
  6. try find element in native context
@mykola-mokhnach
Copy link
Collaborator

I think this is the expected behaviour. The correct approach would be to quit the driver and then start it again with noReset option enabled.

@mykola-mokhnach mykola-mokhnach added UIAutomator2 specific to uiautomator2 driver Needs Info typically non-actionable; needs author to respond labels Jan 25, 2019
@mgrybyk
Copy link

mgrybyk commented Jan 25, 2019

@mykola-mokhnach not likely.
To workaround this I can switch to native context before doing reset.

It should be possible to switch context after app reset.

@mykola-mokhnach mykola-mokhnach added Mobile Chrome related to mobile Chrome driver and removed Needs Info typically non-actionable; needs author to respond UIAutomator2 specific to uiautomator2 driver labels Jan 25, 2019
@Jonahss
Copy link
Member

Jonahss commented Jan 25, 2019

@mgrybyk Hm yeah. I don't think Appium will know which context you are in after the reset. Would it be ok if after reset it switches back to whichever context was the default?

@mgrybyk
Copy link

mgrybyk commented Jan 25, 2019

@Jonahss Yes!
It doesn't matter much for me which context will be after reset but it should be possible to manually set context to a desired one...

@Jonahss
Copy link
Member

Jonahss commented Jan 29, 2019

Ok I was able to reproduce this issue, and my Appium server logs look the same as yours, but the behavior is slightly different.

I wrote a test which switched to a webview context, then called reset command.
After reset, Appium reported that my current context was NATIVE_APP, as expected.
But, my next call to findElement failed because Appium still had an active JSONWP proxy, and attempted to forward the command to chromedriver. My previous webview was not visible, so chromedriver failed to connect and returned an error.

Good find, looks like a bug :)

I'm setting up a PR with a fix, which solves the issue for me locally.

@Jonahss Jonahss added Bug a problem that needs fixing Android related to Android-native driver(s) labels Jan 29, 2019
@Jonahss Jonahss self-assigned this Jan 29, 2019
@mgrybyk
Copy link

mgrybyk commented Jan 29, 2019

@Jonahss thanks a lot!

@Jonahss
Copy link
Member

Jonahss commented Jan 29, 2019

here's the PR appium/appium-android-driver#495

@Jonahss
Copy link
Member

Jonahss commented Feb 5, 2019

PR merged. Will be in the next release, or you can run from latest master

@Jonahss Jonahss closed this as completed Feb 5, 2019
@lock
Copy link

lock bot commented Feb 5, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android related to Android-native driver(s) Bug a problem that needs fixing Mobile Chrome related to mobile Chrome driver
Projects
None yet
4 participants