I am trying to automate a test case in Chrome where I would like to upload an attachment to an email. I use desiredCaps['browserName'] = 'Chrome'. While clicking attachments in email, it opens the Documents in the phone, but I am unable to detect the elements in the Documents screen.
Asked
Active
Viewed 673 times
3 Answers
0
Try this.If you are using ruby
This basically goes into the directory called screenshots
and finds the second picture or the document that is visible inside the directory
find_element(id: "screenshots").find_element(class: "android.widget.ImageView[2]").click
end
This captures the first document/picture visible in the gallery
find_element(id: "").find_element(class: "android.widget.ImageView").click
You can modify it as per your requirement

Emjey
- 2,038
- 3
- 18
- 33
-
Thanks Mrityunjeyan. I think the problem here is initially driver is set to use the Chrome browser (I believe it is the webdriver) and then the Document attach screen which comes up is in native android. So webdriver is not able to reach to the native android screen. So was just checking if there is a way to switch to native android driver. – Thejus Krishna May 26 '17 at 05:31
-
What error does it display when you are trying to detect the documents screen? – Emjey May 26 '17 at 08:25
-
It just times out and says that the element is not present. – Thejus Krishna May 26 '17 at 11:00
0
You shoud change context to from Chromium to 'NATIVE_APP' appium doc about it (http://appium.io/docs/en/writing-running-appium/web/hybrid/) and use Touch Actions for choose you file

Vlad Filimonov
- 1
- 1
-1
In Java, you can use the below code to switch context.
Set<String> contextNames = driver.getContextHandles();
for (final String contextName : contextNames) {
if (contextName.contains("NATIVE")) {
driver.context(contextName);
System.out.println("Switched to Native Context");
}
}
in Python you can try something like this
contextNames = driver.contexts
for aContext in contextNames
if "NATIVE" in aContext:
driver.switch_to.context(aContext)
-
4Excessive promotion of a specific product/resource may be perceived by the community as **spam**. Take a look at the [help], specially [What kind of behavior is expected of users?](//stackoverflow.com/help/behavior)'s last section: _Avoid overt self-promotion_. You might also be interested in [How do I advertise on Stack Overflow?](//stackoverflow.com/help/advertising). – Suraj Rao Jun 02 '17 at 05:54