appium / dotnet-client

Extension to the official Selenium dotnet webdriver
Apache License 2.0
381 stars 188 forks source link

[Bug]: Appium iOS Driver Returns Unexpected Context Values During Automation #841

Open Sarmad-Saleem-SS opened 1 week ago

Sarmad-Saleem-SS commented 1 week ago

I am experiencing an issue with the Appium iOS Driver where the contexts returned during webview automation are incorrect. Despite the Appium server logs showing valid context values, my automation scripts are receiving unexpected strings, specifically "System.Collections.Generic.Dictionary`2[System.String,System.Object]" instead of the expected webview context IDs.

And in server logs

[61112fad][XCUITestDriver@edc5] Responding to client with driver.getContexts() result: [{"id":"NATIVE_APP"},{"id":"WEBVIEW_18156.1","title":"Floor Plan","url":"https://devapp.nfsonline.net/AutomationFP/?AppUserId=0eb8c8cb-5a70-4bca-8739-74881854ee90&Source=mobile&Functionality=floorplan&Platform=flutter","bundleId":"com.nfs.mobile"}]

Sarmad-Saleem-SS commented 1 week ago

@Dor-bl

Dor-bl commented 1 week ago

@SarmadSaleeem can you please share the appium version you are using? Both server and the client. Also the xcuitest driver version might help.

Sarmad-Saleem-SS commented 1 week ago

@Dor-bl Appium Server: 2.11.5 XCuitTest: 5.16.1 Appium Client: 4.4.5

Sarmad-Saleem-SS commented 1 week ago

I am testing on ios 16.0 simulator.

Dor-bl commented 1 week ago

@SarmadSaleeem we no longer support appium client 4.x.y

Please update to version 5.x.y and try again

Sarmad-Saleem-SS commented 1 week ago

@Dor-bl I updated to latest version and fixed all the code issues. Now When I try to run I get this error

"'automationName' can't be blank"

Capability using appiumOptions.AddAdditionalAppiumOption("AutomationName", "xcuitest");

Server log: [Appium] Could not parse W3C capabilities: 'automationName' can't be blank

Dor-bl commented 1 week ago

Appium options already has the automationName property. Just use it directly

Sarmad-Saleem-SS commented 1 week ago

image

@Dor-bl Still getting the same issue. Not able to get the WebView.

var context = driver.Context; MyLogger.Info($"current view is {driver.Context}"); ReadOnlyCollection < string > allContexts = driver.Contexts;

context is returning "Native app" contexts returning list of these strings [0] "System.Collections.Generic.Dictionary`2[System.String,System.Object]"

[1] "System.Collections.Generic.Dictionary`2[System.String,System.Object]"

Dor-bl commented 1 week ago

So it might be a bug, I'll try to have a look at some point in the next few days

Sarmad-Saleem-SS commented 1 week ago

@Dor-bl

This is what I am getting in IOS appium inspector image

And this in Android appium inspector

image

Sarmad-Saleem-SS commented 1 week ago

@Dor-bl I updated my IOS simulator to 16.4

Now On appium inspector I am getting all the contexts

image

but in code still having the same issue.

Sarmad-Saleem-SS commented 1 week ago

The issue is solved now. I was using some additional capabilities. Now I removed all of them and left with only the required ones. Now I am able to get the correct values. Maybe some capability was causing the issue.

Thank you so much @Dor-bl for your assistance.

Dor-bl commented 1 week ago

Good to hear. If you could pinpoint the capability that cause this issue, it will be great for future users.

Sarmad-Saleem-SS commented 1 week ago

Ok I will try to figure out which capability was causing the issue. Then will update here.