aquality-automation / aquality-appium-mobile-dotnet-template

Template project for aquality-appium-mobile-dotnet library.
https://github.com/aquality-automation/aquality-appium-mobile-dotnet
Apache License 2.0
5 stars 3 forks source link

Appium dot net : Unable to check sign in through google #15

Closed aarif313 closed 9 months ago

aarif313 commented 1 year ago

I am working on mobile app automation using aquality dot net framework. In app we have functionality to sign in through Google.

When I click on google button(displayed in WebView) in App it redirects to google Sign-in screen. When I tried to fill email field on google sign in page getting below error

OpenQA.Selenium.WebDriverArgumentException: ''automationName' can't be blank; 'platformName' can't be blank'

These details are already there in "settings.json" but still getting this error.

Note: Before clicking on google button I have switched to WebView as this google button in app appears on webView only

mialeska commented 1 year ago

I guess this could be an issue with the Appium version. Found similar issues reported this year: https://discuss.appium.io/t/appium-2-with-c/38680 https://stackoverflow.com/questions/76538932/openqa-selenium-webdriverexception-automationname-cant-be-blank https://github.com/appium/dotnet-client/issues/631 Could you please share the command which you're using to start Appium service, and your settings.json file with capabilities? Also, please provide version of the library that you're using. Meanwhile, could you please try setting "appium:automationName" and "appium:platformName" with the same values?

aarif313 commented 1 year ago

Below are the contents of my settings.json file, { "environment": "UAT", "profile": "local", "platformName": "Android", "isRemote": true, "remoteConnectionUrl": "http://localhost:4723/wd/hub", "screensLocation": "Project.MobileApps.Framework", "driverSettings": { "android": { "deviceKey": "Android_Real", "capabilities": { "app": "./Resources/Applications/myandroid.apk", "automationName": "UiAutomator2", "appium:settings[imageMatchThreshold]": 0.45, "autoGrantPermissions": true, "autoAcceptAlerts": true } }, "ios": { "deviceKey": "iOS_Real", "capabilities": { "automationName": "XCUITest", "app": "./Resources/Applications/myios.ipa" } } }, "localServiceSettings": { "arguments": { "--allow-insecure": "chromedriver_autodownload" }, "capabilities": { "orientation": "portrait" } }, "timeouts": { "timeoutImplicit": 0, "timeoutCondition": 30, "timeoutScript": 10, "timeoutPageLoad": 60, "timeoutPollingInterval": 300, "timeoutCommand": 60 }, "retry": { "number": 2, "pollingInterval": 300 }, "logger": { "language": "en" }, "elementCache": { "isEnabled": true }, "touchActions": { "swipe": { "duration": 1, "retries": 5, "verticalOffset": 0.2, "horizontalOffset": 0.5 } }, "visualization": { "defaultThreshold": 0.012, "comparisonWidth": 16, "comparisonHeight": 16, "pathToDumps": "./Resources/VisualDumps/" } }

I use below command to start Appium server, appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images

mialeska commented 1 year ago

Okay, what about Appium server version and Aquality version? Does this error appear on iOS or on Android? I can see that platformName is missing for the iOS. Also, have you tried "appium:automationName" and "appium:platformName" capabilities?

aarif313 commented 1 year ago

Appium Server Version : v2.0.0-beta.52 Aquality Version : 4.1.0

This error appears on Android, Not yet tested on iOS.

And yes I tried with "appium:automationName" and "appium:platformName" capabilities but it was showing error again as below, System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.ArgumentException : There are no values found by path '.platformName' in JSON file 'settings.json'

Kindly help.

mialeska commented 1 year ago

I am working on mobile app automation using aquality dot net framework. In app we have functionality to sign in through Google.

When I click on google button(displayed in WebView) in App it redirects to google Sign-in screen. When I tried to fill email field on google sign in page getting below error

OpenQA.Selenium.WebDriverArgumentException: ''automationName' can't be blank; 'platformName' can't be blank'

I think what is really happening is the another app (e.g. Chrome or some Google app) opens when you click on that Google button. For this app, capabilities probably are not defined.

What I can think as solution:

  1. Investigate google Sign-in screen with Appium inspector. Identify the app by sending Android activity command.
  2. Try switching to NATIVE_APP view after navigation to google Sign in screen, then explore with inspector
  3. If previous steps don't help, try starting Appium server with passing --default-capabilities for automationName and platformName https://appium.io/docs/en/2.1/cli/args/ image image
aarif313 commented 1 year ago

I itried multiple time to run appium appium with default capabilities but its not running,

C:\Users\msoudagar>appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities/-dc

[ERROR] Unrecognized arguments: --default-capabilities/-dc

C:\Users\msoudagar>appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities-dc

[ERROR] Unrecognized arguments: --default-capabilities-dc

C:\Users\msoudagar>appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities -dc usage: index.js server [-h] [--address ADDRESS] [--allow-cors] [--allow-insecure ALLOW_INSECURE] [--base-path BASE_PATH] [--callback-address CALLBACK_ADDRESS] [--callback-port CALLBACK_PORT] [--debug-log-spacing] [--default-capabilities DEFAULT_CAPABILITIES] [--deny-insecure DENY_INSECURE] [--keep-alive-timeout KEEP_ALIVE_TIMEOUT] [--local-timezone] [--log LOG] [--log-filters LOG_FILTERS] [--log-level LOG_LEVEL] [--log-no-colors] [--log-timestamp] [--long-stacktrace] [--no-perms-check] [--nodeconfig NODECONFIG] [--port PORT] [--relaxed-security] [--session-override] [--strict-caps] [--tmp TMP] [--trace-dir TRACE_DIR] [--use-drivers USE_DRIVERS] [--use-plugins USE_PLUGINS] [--webhook WEBHOOK] [--shell] [--show-build-info] [--show-config] [--config CONFIGFILE]

index.js server: error: argument --default-capabilities/-dc: expected one argument

C:\Users\msoudagar>appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images -dc usage: index.js server [-h] [--address ADDRESS] [--allow-cors] [--allow-insecure ALLOW_INSECURE] [--base-path BASE_PATH] [--callback-address CALLBACK_ADDRESS] [--callback-port CALLBACK_PORT] [--debug-log-spacing] [--default-capabilities DEFAULT_CAPABILITIES] [--deny-insecure DENY_INSECURE] [--keep-alive-timeout KEEP_ALIVE_TIMEOUT] [--local-timezone] [--log LOG] [--log-filters LOG_FILTERS] [--log-level LOG_LEVEL] [--log-no-colors] [--log-timestamp] [--long-stacktrace] [--no-perms-check] [--nodeconfig NODECONFIG] [--port PORT] [--relaxed-security] [--session-override] [--strict-caps] [--tmp TMP] [--trace-dir TRACE_DIR] [--use-drivers USE_DRIVERS] [--use-plugins USE_PLUGINS] [--webhook WEBHOOK] [--shell] [--show-build-info] [--show-config] [--config CONFIGFILE]

index.js server: error: argument --default-capabilities/-dc: expected one argument

mialeska commented 1 year ago

Please take a look on example command: https://appium.readthedocs.io/en/stable/en/writing-running-appium/default-capabilities-arg/ Should be something like this in your case: appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities '{"automationName": "UiAutomator2", "platformName": "Android"}'

aarif313 commented 1 year ago

Hi,

Being an Windows user I tried below command and run Appium server.

appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities "{\"appium:automationName\": \"UiAutomator2\", \"appium:platformName\": \"Android\"}"

But still I am not able to enter email Id in google screen.

Let me tell you again what is happening step-by-step,

  1. Open App (Native View)
  2. Clicking on Sign in button in App (Native View)
  3. I Switch to WebView
  4. Then app open in WebView where is ask to enter email and password and also allows Sign-In through Google
  5. Clicking on Google button then it open another app Google app[In WebView only] for Android and ask to enter Google credentials
  6. I have already inspected this google sign in screen but unable to enter email

As you suggested I tried by switching to NATIVE View as well before Step-6 but still didn't work.

aarif313 commented 1 year ago

This is the error this time,

Message:  OpenQA.Selenium.WebDriverException : An unknown server-side error occurred while processing the command. Original error: invalid argument: cannot parse capability: goog:chromeOptions from invalid argument: unrecognized chrome option: prefs

mialeska commented 1 year ago

Okay, I think I have found similar issue in Appium forums, so you will need to follow the suggestions from there: https://discuss.appium.io/t/appium-inspector-windows-call-to-switchcontext-failed/38105 They say in related issue: https://github.com/appium/appium-inspector/issues/465

The fix should be included in appium-uiautomator2-driver v2.0.4 or later.

So first suggestion would be to install latest version of UIAutomator2 driver before starting the appium server: appium driver update uiautomator2 Also it could be that you need to provide more capabilities to driver as suggested here https://github.com/appium/appium/issues/16514#issuecomment-1506592913 (make sure that you use your app's package name) Something like this:

appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities '{"automationName": "UiAutomator2", "platformName": "Android", "goog:chromeOptions": {    "androidUseRunningApp": true,    “androidProcess”: “com.my.awesome.app”,    "androidPackage": "com.my.awesome.app"}}'

Also it could be a chromedriver version mismatch to installed chrome.. Also please check out this comment: https://monorail-prod.appspot.com/p/chromedriver/issues/detail?id=1206#c4

mialeska commented 1 year ago

also you can inspect what happens in appium server logs when you getting the error

aarif313 commented 1 year ago

Sharing server logs for your reference,

[HTTP] --> POST /wd/hub/session [HTTP] {"capabilities":{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}} [debug] [AppiumDriver@c96b] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}] [AppiumDriver@c96b] Plugins which can handle cmd 'createSession': images [AppiumDriver@c96b] Plugin images is now handling cmd 'createSession' [AppiumDriver@c96b] Executing default handling behavior for command 'createSession' [debug] [AppiumDriver@c96b] Event 'newSessionRequested' logged at 1695900429763 (16:57:09 GMT+0530 (India Standard Time)) [Appium] Could not parse W3C capabilities: 'automationName' can't be blank; 'platformName' can't be blank [debug] [AppiumDriver@c96b] Event 'newSessionStarted' logged at 1695900429767 (16:57:09 GMT+0530 (India Standard Time)) [debug] [AppiumDriver@c96b] Encountered internal error running command: InvalidArgumentError: 'automationName' can't be blank; 'platformName' can't be blank [debug] [AppiumDriver@c96b] at processCapabilities (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\capabilities.js:329:13) [debug] [AppiumDriver@c96b] at parseCapsForInnerDriver (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\utils.js:135:40) [debug] [AppiumDriver@c96b] at AppiumDriver.createSession (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:242:49) [debug] [AppiumDriver@c96b] at commandExecutor (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.js:122:18) [debug] [AppiumDriver@c96b] at AppiumDriver.executeCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.js:139:15) [debug] [AppiumDriver@c96b] at processTicksAndRejections (node:internal/process/task_queues:96:5) [debug] [AppiumDriver@c96b] at defaultBehavior (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:669:16) [debug] [AppiumDriver@c96b] at ImageElementPlugin.handle (C:\Users\msoudagar.appium\node_modules\@appium\images-plugin\lib\plugin.js:75:12) [debug] [AppiumDriver@c96b] at C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:726:16 [debug] [AppiumDriver@c96b] at AppiumDriver.executeWrappedCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:763:16) [debug] [AppiumDriver@c96b] at AppiumDriver.executeCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:685:17) [debug] [AppiumDriver@c96b] at asyncHandler (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\protocol\protocol.js:387:19) [HTTP] <-- POST /wd/hub/session 400 174 ms - 1806 [HTTP] [HTTP] --> POST /wd/hub/session [HTTP] {"capabilities":{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}} [debug] [AppiumDriver@c96b] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}] [AppiumDriver@c96b] Plugins which can handle cmd 'createSession': images [AppiumDriver@c96b] Plugin images is now handling cmd 'createSession' [AppiumDriver@c96b] Executing default handling behavior for command 'createSession' [debug] [AppiumDriver@c96b] Event 'newSessionRequested' logged at 1695900432344 (16:57:12 GMT+0530 (India Standard Time)) [Appium] Could not parse W3C capabilities: 'automationName' can't be blank; 'platformName' can't be blank [debug] [AppiumDriver@c96b] Event 'newSessionStarted' logged at 1695900432346 (16:57:12 GMT+0530 (India Standard Time)) [debug] [AppiumDriver@c96b] Encountered internal error running command: InvalidArgumentError: 'automationName' can't be blank; 'platformName' can't be blank [debug] [AppiumDriver@c96b] at processCapabilities (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\capabilities.js:329:13) [debug] [AppiumDriver@c96b] at parseCapsForInnerDriver (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\utils.js:135:40) [debug] [AppiumDriver@c96b] at AppiumDriver.createSession (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:242:49) [debug] [AppiumDriver@c96b] at commandExecutor (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.js:122:18) [debug] [AppiumDriver@c96b] at AppiumDriver.executeCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.js:139:15) [debug] [AppiumDriver@c96b] at processTicksAndRejections (node:internal/process/task_queues:96:5) [debug] [AppiumDriver@c96b] at defaultBehavior (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:669:16) [debug] [AppiumDriver@c96b] at ImageElementPlugin.handle (C:\Users\msoudagar.appium\node_modules\@appium\images-plugin\lib\plugin.js:75:12) [debug] [AppiumDriver@c96b] at C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:726:16 [debug] [AppiumDriver@c96b] at AppiumDriver.executeWrappedCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:763:16) [debug] [AppiumDriver@c96b] at AppiumDriver.executeCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:685:17) [debug] [AppiumDriver@c96b] at asyncHandler (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\protocol\protocol.js:387:19) [HTTP] <-- POST /wd/hub/session 400 13 ms - 1806 [HTTP] [HTTP] --> POST /wd/hub/session [HTTP] {"capabilities":{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}} [debug] [AppiumDriver@c96b] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}] [AppiumDriver@c96b] Plugins which can handle cmd 'createSession': images [AppiumDriver@c96b] Plugin images is now handling cmd 'createSession' [AppiumDriver@c96b] Executing default handling behavior for command 'createSession' [debug] [AppiumDriver@c96b] Event 'newSessionRequested' logged at 1695900434726 (16:57:14 GMT+0530 (India Standard Time)) [Appium] Could not parse W3C capabilities: 'automationName' can't be blank; 'platformName' can't be blank [debug] [AppiumDriver@c96b] Event 'newSessionStarted' logged at 1695900434728 (16:57:14 GMT+0530 (India Standard Time)) [debug] [AppiumDriver@c96b] Encountered internal error running command: InvalidArgumentError: 'automationName' can't be blank; 'platformName' can't be blank [debug] [AppiumDriver@c96b] at processCapabilities (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\capabilities.js:329:13) [debug] [AppiumDriver@c96b] at parseCapsForInnerDriver (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\utils.js:135:40) [debug] [AppiumDriver@c96b] at AppiumDriver.createSession (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:242:49) [debug] [AppiumDriver@c96b] at commandExecutor (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.js:122:18) [debug] [AppiumDriver@c96b] at AppiumDriver.executeCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.js:139:15) [debug] [AppiumDriver@c96b] at processTicksAndRejections (node:internal/process/task_queues:96:5) [debug] [AppiumDriver@c96b] at defaultBehavior (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:669:16) [debug] [AppiumDriver@c96b] at ImageElementPlugin.handle (C:\Users\msoudagar.appium\node_modules\@appium\images-plugin\lib\plugin.js:75:12) [debug] [AppiumDriver@c96b] at C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:726:16 [debug] [AppiumDriver@c96b] at AppiumDriver.executeWrappedCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:763:16) [debug] [AppiumDriver@c96b] at AppiumDriver.executeCommand (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\lib\appium.js:685:17) [debug] [AppiumDriver@c96b] at asyncHandler (C:\Users\msoudagar\AppData\Roaming\npm\node_modules\appium\node_modules\@appium\base-driver\lib\protocol\protocol.js:387:19) [HTTP] <-- POST /wd/hub/session 400 14 ms - 1806

mialeska commented 1 year ago

@aarif313 I don't see you're passing any capabilities in these logs.

[HTTP] --> POST /wd/hub/session [HTTP] {"capabilities":{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}} [debug] [AppiumDriver@c96b] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}]

Could you please try starting Appium server with these capabilities (only place your package name first)? appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities '{"automationName": "UiAutomator2", "platformName": "Android", "goog:chromeOptions": { "androidUseRunningApp": true, “androidProcess”: “com.my.awesome.app”, "androidPackage": "com.my.awesome.app"}}'

mialeska commented 1 year ago

@aarif313 at your logs

[HTTP] {"capabilities":{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}} [debug] [AppiumDriver@c96b] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"browserName":"chrome","pageLoadStrategy":"normal","goog:chromeOptions":{}}]}] [AppiumDriver@c96b] Plugins which can handle cmd 'createSession': images [AppiumDriver@c96b] Plugin images is now handling cmd 'createSession' [AppiumDriver@c96b] Executing default handling behavior for command 'createSession' [debug] [AppiumDriver@c96b] Event 'newSessionRequested' logged at 1695900429763 (16:57:09 GMT+0530 (India Standard Time)) [Appium] Could not parse W3C capabilities: 'automationName' can't be blank; 'platformName' can't be blank

I don't see you passing any capabilities for the session created. Please try to start Appium server with the default capabilities, like appium --allow-insecure chromedriver_autodownload --base-path /wd/hub --use-plugins=images --default-capabilities '{"automationName": "UiAutomator2", "platformName": "Android", "goog:chromeOptions": { "androidUseRunningApp": true, “androidProcess”: “com.my.awesome.app”, "androidPackage": "com.my.awesome.app"}}' then recheck your logs

aarif313 commented 9 months ago

@mialeska @aqualityAutomation

I have updated elements of google sign in with Appium elements and it solves this issue.

Thanks for your support.