Skip to content
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

Can we use headless mode for UI/Functional testing? #19

Open
Akash-ramesh opened this issue Feb 26, 2024 · 4 comments
Open

Can we use headless mode for UI/Functional testing? #19

Akash-ramesh opened this issue Feb 26, 2024 · 4 comments

Comments

@Akash-ramesh
Copy link

Akash-ramesh commented Feb 26, 2024

Hi @amrsa1 ,

Thanks in advance for the repo.

I am new to automation and I am trying to integrate my test scripts written in python and using appium technology to pipeline. Can we use headless mode for UI testing?

I am not able to launch emulator in headed mode. I am getting the following error :

_IINFO    | Storing crashdata in: , detection is enabled for process: 1668
INFO    | Duplicate loglines will be removed, if you wish to see each individual line launch with the -log-nofilter flag.
INFO    | Increasing RAM size to 3072MB
WARNING | File System is not ext4, disable QuickbootFileBacked feature
INFO    | Warning: could not connect to display  ((null):0, (null))
INFO    | Info: Could not load the Qt platform plugin "xcb" in "/opt/android/emulator/lib64/qt/plugins" even though it was found. ((null):0, (null))
Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.
 ((null):0, (null))
INFO    | Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.._

I am able to launch emulator in headless mode, but my test cases are failing with Element not found exception

_File "/usr/local/lib/python3.9/dist-packages/appium/webdriver/webdriver.py", line 409, in find_element
         return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value']
       File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webdriver.py", line 345, in execute
         self.error_handler.check_response(response)
       File "/usr/local/lib/python3.9/dist-packages/appium/webdriver/errorhandler.py", line 122, in check_response
         raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
     Stacktrace:
     NoSuchElementError: An element could not be located on the page using the given search parameters.
         at AndroidUiautomator2Driver.findElOrEls (/root/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:75:11)
         at processTicksAndRejections (node:internal/process/task_queues:95:5)
         at AndroidUiautomator2Driver.findElOrElsWithProcessing (/usr/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:60:12)
         at AndroidUiautomator2Driver.findElement (/usr/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:75:12)_
@amrsa1
Copy link
Owner

amrsa1 commented Feb 28, 2024

@Akash-ramesh

how you are trying to run the emulator in headed mode ?, only way is Via vnc, you cant run it in headed mode using terminal.
Regarding test failing best thing todo is to take screenshot on failure in order to be able to debug.

@SachinNodeShell
Copy link

Hi @Akash-ramesh I have been encountering the same issue as well, did you find any solution to it?
NOTE Appium works fine on my own device locally on the emulator, however when I try to run it in headless mode it throws NoSuchElementError: An element could not be located on the page using the given search parameters.
I tried adding a delay to ensure the emulator and the app launch were ready to run the tests, but I still got the same error!

@amrsa1 can you please confirm if we can run the unit tests in headless mode?

@amrsa1
Copy link
Owner

amrsa1 commented Jun 22, 2024

Headless mode should be working fine but somtimes the android image is not stable in headless mode, neverthless you can still overcome the android crashing issue, follow up this article to resolve this issue

Check the debugging section
https://webdriver.io/blog/2023/05/31/guied-for-xplatform-nativeMobile-app

@SachinNodeShell
Copy link

Thanks @amrsa1 for the quick response, I will check the article!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants