appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.22k stars 758 forks source link

How to deal with the Maps.TransformedEntriesMap type result returned from getContextHandles method? #1957

Closed shinobi01 closed 1 year ago

shinobi01 commented 1 year ago

Description

I'm creating test cases on iOS hybrid application, we have multiple web views when I trying to switch context, so I used .fullContextList() capability to show more informations to identifying which web view is going to be switch. but I got Maps.TransformedEntriesMap type results from getContextHandles method, how could I got the information from it?

Environment

Details

image

Code To Reproduce Issue [ Good To Have ]

Capabilities: return new XCUITestOptions() .setUdid(UDID) .setPlatformVersion(prop.getProperty("platformVersion")) .setDeviceName(prop.getProperty("deviceName")) .setApp(appLocation) .setAutomationName(prop.getProperty("automationName")) .fullReset() .setUseNewWDA(false) .fullContextList() .clearSystemFiles() .setNewCommandTimeout(Duration.ofSeconds(300)) .showXcodeLog(); Code Snippet: // AppiumDriver driver Set contextNames = ((SupportsContextSwitching)world.driver).getContextHandles();

mykola-mokhnach commented 1 year ago

https://github.com/google/guava/blob/a9c2970e1cdff1e71a27a75866b083f3ae60d6f2/guava/src/com/google/common/collect/Maps.java#L2172

It implements the Map interface and thus could be interacted as any other normal map

shinobi01 commented 1 year ago

@mykola-mokhnach, thank you for your response. yes, we could get the info in follow actions, just post here in case anyone needed. String id = (String) ((Map<?, ?>) contextName).get("id");