-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Is there a way to assign name for web context in app under test? #4911
Comments
@NickAb AFAIK appium does not assign these names. You can always store it in variables and use variable instead to make your code more readable |
Yeah, though this would be a useful feature, there's no way I know of to dependably keep track of webviews and make sure the same one always gets the same name. If you think about it, it is against the selenium/appium model to name elements as well. The appium server just assigns elements IDs and it is up to the test code to keep track of elements and assign them to variables. Which appium client do you use? If you use the java client, maybe we could have the Contexts be full Objects instead of strings. Otherwise, you can always use the Page Object model of testing to assign your contexts to names. |
@Jonahss actually the problem is not in storing context names in tests, but in correlating context names and corresponding UIAWebViews in native context. One option I see is iterating over all web view contexts and checking some attribute in page source to build a map between auto assigned names (like In webkit-remote-debbuger besides page key (the number that gets appended to
If so, it seems that those values can be used as constant context identifiers. And I think it will certainly help in our case. I use python bindings. What do you think about it? |
Oh I see. We could name the webviews based on their accessibility id's or other attributes as well. That's a good suggestion, but I don't think it's possible :( For example, the way we get a list of the chrome webviews on an Android app is we call A workaround for you: You can add a hidden element in your webviews which records the accessibility Id of the webview. So you can change contexts to each webview and find the hidden element and get the text. You can also call |
@Jonahss after reading the code I thought that using accessibility ids for context names would be impossible. And the workaround will work for me, but it will require sending quite a few requests and commands to Appium. |
I wonder if we can find a way to get context metadata for android as well, and then can have /contexts return object for both. Having the /contexts endpoint return objects with optional metadata is a good idea. Let's see if @jlipps is ok with editing the mobile json wire protocol to include this. If we make the metadata optional, then it can be included with iOS and not included with Android for now. If @jlipps likes this, we would love a pull request! |
👍 would be a big improvement for correct context discovery instead of switching and trying to find something context specific |
sorry, no, however if you want to engage more of the spec authors (which would need to happen anyway), feel free to chime in at http://github.com/SeleniumHQ/mobile-spec or mobile-jsonwp-spec@googlegroups.com |
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. |
At the moment you can switch to web context using names like
WEBVIEW_1
that are assigned by Appium. Is there a way to specify name for web context based on automation id of element or something?Manually assigning names for web contexts will allow:
The text was updated successfully, but these errors were encountered: