Tests when run multiple times then driver is not working after getOrientaion(used for making the script wait) method is run - appium-android

I've created an appium script and my testcases contain wait functionality i.e. I'm making any app like youtube or any game wait for long duration of times.
The Wait code is like this:
for(int j=1; j<((min*2)+1);j++)
{
Thread.sleep(30000);
driver.getOrientation();}
Here min is the number of minutes that i'm trying to wait the application.
I'm also using invocationCount attribute of #Test testng to run tests multiple times.
After first Iteration when this wait section comes then the script crashes i.e. the next driver command like driver.findelement... is not working.
It is giving error like this:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
Build info: version: '4.1.3', revision: '7b1ebf28ef'
System info: host: 'DESKTOP-M7R3JD6', ip: '192.168.52.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.2'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [9d59677d-0ce4-4720-b837-8964d3946cf7, findElement {using=accessibility id, value=Camera}]
Capabilities {appium:adbExecTimeout: 20000, appium:appActivity: com.android.dialer.main.imp..., appium:appPackage: com.sh.smart.caller, appium:databaseEnabled: false, appium:desired: {adbExecTimeout: 20000, appActivity: com.android.dialer.main.imp..., appPackage: com.sh.smart.caller, deviceName: Infinix HOT 12 PRO, newCommandTimeout: 36000, platformName: android, platformVersion: 12, udid: 085733723N000129}, appium:deviceApiLevel: 31, appium:deviceManufacturer: INFINIX, appium:deviceModel: Infinix X668, appium:deviceName: 085733723N000129, appium:deviceScreenDensity: 320, appium:deviceScreenSize: 720x1612, appium:deviceUDID: 085733723N000129, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: true, appium:newCommandTimeout: 36000, appium:pixelRatio: 2, appium:platformVersion: 12, appium:statBarHeight: 72, appium:takesScreenshot: true, appium:udid: 085733723N000129, appium:viewportRect: {height: 1372, left: 0, top: 72, width: 720}, appium:warnings: {}, appium:webStorageEnabled: false, platformName: android}
Session ID: 9d59677d-0ce4-4720-b837-8964d3946cf7
What do i do to make it work?

Related

How to debug session leaking or close all sessions in python MongoDB?

It is my first time to use MongoDB to manage an image dataset(~10 million images).
My environment is MongoDB 5.0.6 with PymongoDB 4.0.2 and Python 3.9.6 on Ubuntu 18.04.
My dataset is accessing PyMongoDB and then it is used to train a DNN in Pytorch. My code warns at the begining:
UserWarning: MongoClient opened before fork.
Create MongoClient only after forking.
See PyMongo's documentation for details: https://pymongo.readthedocs.io/en/stable/faq.html#is-pymongo-fork-safe
(I check this url and get nothing. I think I indeed recreate the client each time when the class is instantiaed)
After running for a while, my code crashs, and exit
Unable to add session ID ffd152cf-97d3-454a-882a-c6fc693e2985 - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
into the cache because the number of active sessions is too high,
full error:
{'ok': 0.0,
'errmsg': 'Unable to add session ID ffd152cf-97d3-454a-882a-c6fc693e2985 - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= into the cache because the number of active sessions is too high',
'code': 261,
'codeName': 'TooManyLogicalSessions'}Unable to add session ID 85b35e6c-fc83-41d1-915b-83e6841c5467 - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= into the cache because the number of active sessions is too high, full error: {'ok': 0.0, 'errmsg': 'Unable to add session ID 85b35e6c-fc83-41d1-915b-83e6841c5467 - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= into the cache because the number of active sessions is too high',
'code': 261,
'codeName': 'TooManyLogicalSessions'}
As the error message, It seems I just opened too many sessions.
How can I check current active sessions in PyMongoDB? How can I close all sessions? Or how can I further debug this problem?
Thank you very much! My active sessions' number and my dataset code sample is offered as shown below:
1. Check the active sessions
My active sessions (db.serverStatus().connections) are indeed increasing:
{
current: 6,
available: 51194,
totalCreated: 199,
active: 2,
threaded: 6,
exhaustIsMaster: 0,
exhaustHello: 1,
awaitingTopologyChanges: 1
}
to
{
current: 156,
available: 51044,
totalCreated: 361,
active: 54,
threaded: 156,
exhaustIsMaster: 0,
exhaustHello: 51,
awaitingTopologyChanges: 51
}
and 5 minutes later, my program broke. (I don't know how to get this result from PymongoDB instead of mongosh. So I can only check it manually periodly. At this moment It seems there are still 51044 availiable, and should not be consumed up so quickly only in 5 minutes.)
2. my sample dataset code
like:
from torch.utils.data import Dataset
from pymongo import MongoClient
class MongoDataset(Dataset):
def __init__(self, dbName):
client = MongoClient(host = '127.0.0.1', port = 27017, connect=False)
db = client[dbName]
self.dataTable = db["dataTable"]
def getData(self, _id):
return self.dataTable.find_one({"_id" : _id})
def __len__(self):
return self.dataTable.estimated_document_count()
This class will be automatically forked, and recreated.

Bitbake server does not start

I am having some trouble with building the Yocto project, hope I can find some help. Is there any way to fix the following issue? Let me know if you need any more information. Thanks.
My goal
I am building the default image from this guide : https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html
This build takes up a lot of space, so I want to build it on a network drive.
Current situation
I am able to finish the build normally if I am using a normal folder.
If I use the the shared drive that is mounted in the system, the build never starts. The error looks like this :
$ bitbake core-image-sato
NOTE: Bitbake server didn't start within 5 seconds, waiting for 90
ERROR: Error parsing configuration files
Traceback (most recent call last):
File "/mnt/NetworkShare/yocto/poky/bitbake/lib/bb/persist_data.py", line 45, in SQLTable.wrap_func(*args=('CREATE TABLE IF NOT EXISTS BB_URI_HEADREVS(key TEXT PRIMARY KEY NOT NULL, value TEXT);',), **kwargs={}):
if self.connection is None and reconnect:
> self.reconnect()
File "/mnt/NetworkShare/yocto/poky/bitbake/lib/bb/persist_data.py", line 105, in SQLTable.reconnect():
self.connection.text_factory = str
> self._setup_database()
File "/mnt/NetworkShare/yocto/poky/bitbake/lib/bb/persist_data.py", line 50, in SQLTable.wrap_func(*args=(), **kwargs={}):
try:
> return f(self, *args, **kwargs)
except sqlite3.OperationalError as exc:
File "/mnt/NetworkShare/yocto/poky/bitbake/lib/bb/persist_data.py", line 79, in SQLTable.wrap_func(*args=(), **kwargs={}):
with contextlib.closing(self.connection.cursor()) as cursor:
> return f(self, cursor, *args, **kwargs)
return wrap_func
File "/mnt/NetworkShare/yocto/poky/bitbake/lib/bb/persist_data.py", line 93, in SQLTable._setup_database(cursor=<sqlite3.Cursor object at 0x7f3d59c5dab0>):
def _setup_database(self, cursor):
> cursor.execute("pragma synchronous = off;")
# Enable WAL and keep the autocheckpoint length small (the default is
sqlite3.OperationalError: disk I/O error
Details
The /etc/fstab line to mount the drive is :
NetworkShare /mnt/NetworkShare 9p trans=virtio,version=9p2000.L,_netdev,rw 0 0
The host is Ubuntu server 20.04 running in a VM inside UnRAID. I don't think the VM is the issue (It's possible that I am very wrong) because I get the same error if I mount an external share on my own computer (OpenSuse Tumbleweed) and try to build in it.
The bitbake-cookerdaemon.log :
1221 13:38:18.293775 --- Starting bitbake server pid 1221 at 2022-01-19 13:38:18.293689 ---
1221 13:38:18.333537 Started bitbake server pid 1221
1221 13:38:18.339125 Entering server connection loop
1221 13:38:18.340399 Accepting [<socket.socket fd=6, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, laddr=bitbake.sock>] ([])
1221 13:38:18.341382 Processing Client
1221 13:38:18.342099 Connecting Client
1221 13:38:18.343689 Running command ['setFeatures', [2]]
1221 13:38:18.344805 Command Completed
1221 13:38:18.346085 Running command ['updateConfig', {'abort': True, 'force': False, 'invalidate_stamp': None, 'dry_run': False, 'dump_signatures': [], 'extra_assume_provided': [], 'profile': False, 'prefile': [], 'postfile': [], 'server_timeout': None, 'nosetscene': False, 'setsceneonly': False, 'skipsetscene': False, 'runall': None, 'runonly': None, 'writeeventlog': None, 'build_verbose_shell': False, 'build_verbose_stdout': False, 'default_loglevel': 20, 'debug_domains': {}}, {'SHELL': '/bin/bash', 'PWD': '/mnt/NetworkShare/yocto/poky/build', 'LOGNAME': 'metics', 'HOME': '/home/metics', 'BBPATH': '/mnt/NetworkShare/yocto/poky/build', 'BB_ENV_EXTRAWHITE': 'ALL_PROXY BBPATH_EXTRA BB_LOGCONFIG BB_NO_NETWORK BB_NUMBER_THREADS BB_SETSCENE_ENFORCE BB_SRCREV_POLICY DISTRO FTPS_PROXY FTP_PROXY GIT_PROXY_COMMAND HTTPS_PROXY HTTP_PROXY MACHINE NO_PROXY PARALLEL_MAKE SCREENDIR SDKMACHINE SOCKS5_PASSWD SOCKS5_USER SSH_AGENT_PID SSH_AUTH_SOCK STAMPS_DIR TCLIBC TCMODE all_proxy ftp_proxy ftps_proxy http_proxy https_proxy no_proxy ', 'USER': 'metics', 'PATH': '/mnt/NetworkShare/yocto/poky/scripts:/mnt/NetworkShare/yocto/poky/bitbake/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'LC_ALL': 'en_US.UTF-8', 'TERMCAP': 'SC|screen.xterm-256color|VT 100/ANSI X3.64 virtual terminal:DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:UP=\\E[%dA:bs:bt=\\E[Z:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:ct=\\E[3g:do=^J:nd=\\E[C:pt:rc=\\E8:rs=\\Ec:sc=\\E7:st=\\EH:up=\\EM:le=^H:bl=^G:cr=^M:it#8:ho=\\E[H:nw=\\EE:ta=^I:is=\\E)0:li#51:co#110:am:xn:xv:LP:sr=\\EM:al=\\E[L:AL=\\E[%dL:cs=\\E[%i%d;%dr:dl=\\E[M:DL=\\E[%dM:dc=\\E[P:DC=\\E[%dP:im=\\E[4h:ei=\\E[4l:mi:IC=\\E[%d#:ks=\\E[?1h\\E=:ke=\\E[?1l\\E>:vi=\\E[?25l:ve=\\E[34h\\E[?25h:vs=\\E[34l:ti=\\E[?1049h:te=\\E[?1049l:us=\\E[4m:ue=\\E[24m:so=\\E[3m:se=\\E[23m:mb=\\E[5m:md=\\E[1m:mh=\\E[2m:mr=\\E[7m:me=\\E[m:ms:Co#8:pa#64:AF=\\E[3%dm:AB=\\E[4%dm:op=\\E[39;49m:AX:vb=\\Eg:G0:as=\\E(0:ae=\\E(B:ac=\\140\\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:po=\\E[5i:pf=\\E[4i:Km=\\E[M:k0=\\E[10~:k1=\\EOP:k2=\\EOQ:k3=\\EOR:k4=\\EOS:k5=\\E[15~:k6=\\E[17~:k7=\\E[18~:k8=\\E[19~:k9=\\E[20~:k;=\\E[21~:F1=\\E[23~:F2=\\E[24~:kB=\\E[Z:kh=\\E[1~:#1=\\E[1~:kH=\\E[4~:#7=\\E[4~:kN=\\E[6~:kP=\\E[5~:kI=\\E[2~:kD=\\E[3~:ku=\\EOA:kd=\\EOB:kr=\\EOC:kl=\\EOD:km:', 'WINDOW': '0', 'XDG_SESSION_TYPE': 'tty', 'MOTD_SHOWN': 'pam', 'LANG': 'en_US.UTF-8', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'SSH_CONNECTION': '10.0.0.12 60522 10.0.0.19 22', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'XDG_SESSION_CLASS': 'user', 'PYTHONPATH': '/mnt/NetworkShare/yocto/poky/bitbake/lib:', 'TERM': 'screen.xterm-256color', 'LESSOPEN': '| /usr/bin/lesspipe %s', 'SHLVL': '2', 'XDG_SESSION_ID': '1', 'XDG_RUNTIME_DIR': '/run/user/1000', 'SSH_CLIENT': '10.0.0.12 60522 22', 'XDG_DATA_DIRS': '/usr/local/share:/usr/share:/var/lib/snapd/desktop', 'STY': '1116.pts-0.ubuntuserver', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', 'BUILDDIR': '/mnt/NetworkShare/yocto/poky/build', 'SSH_TTY': '/dev/pts/0', 'OLDPWD': '/mnt/NetworkShare/yocto/poky', '_': '/mnt/NetworkShare/yocto/poky/bitbake/bin/bitbake'}, ['/mnt/NetworkShare/yocto/poky/bitbake/bin/bitbake', 'core-image-sato']]
1221 13:38:33.830099 Command Completed
1221 13:38:33.831731 Processing Client
1221 13:38:33.832344 Disconnecting Client
1221 13:38:33.833129 No timeout, exiting.
1221 13:38:33.933875 Exiting
1221 13:38:33.942717 Original lockfile contents: ['1221\n']
1221 13:38:33.954461 Exiting as we could obtain the lock
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/mnt/NetworkShare/yocto/poky/build/bitbake-cookerdaemon.log' mode='a+' encoding='UTF-8'>
It means your hard disk is full. You should delete some files before re-running job to create a new image.

Visual Studio Code - Blank Window no border

It first started with just a blank window with some purple marking at the bottom.
I have used it for a few years and updated regularly and all of a sudden this happened when i start visual studio code. Never had any problems before.
Empty Window Purple
I have tried
--disable-gpu
--disable-extensions
I have tried other projects that i have and i have tried to open just single files outside of projects..
I also installed Insider and same thing with that..
No difference
I have uninstalled twice and the second time i deleted all the left over folders too before installing again and when i started it, and after that it was just a complete blank window instead.
Empty Window
I tested to run verbose but i dont understand the info it gives..
[main 2021-07-13T14:16:34.370Z] Starting VS Code
[main 2021-07-13T14:16:34.371Z] from: r:\appdata\local\Programs\Microsoft VS Code\resources\app
[main 2021-07-13T14:16:34.371Z] args: {
_: [],
diff: false,
add: false,
goto: false,
'new-window': false,
'reuse-window': false,
wait: false,
help: false,
'list-extensions': false,
'show-versions': false,
version: false,
verbose: true,
status: false,
'prof-startup': false,
'no-cached-data': false,
'prof-v8-extensions': false,
'disable-extensions': false,
'disable-gpu': false,
telemetry: false,
debugRenderer: false,
logExtensionHostCommunication: false,
'skip-release-notes': false,
'skip-welcome': false,
'disable-telemetry': false,
'disable-updates': false,
'disable-keytar': false,
'disable-workspace-trust': false,
'disable-crash-reporter': false,
'crash-reporter-id': '2cc1e8c2-4377-4843-9280-055c7d494850',
'skip-add-to-recently-opened': false,
'unity-launch': false,
'open-url': false,
'file-write': false,
'file-chmod': false,
'driver-verbose': false,
force: false,
'do-not-sync': false,
trace: false,
'force-user-env': false,
'force-disable-user-env': false,
'open-devtools': false,
__sandbox: false,
'no-proxy-server': false,
nolazy: false,
'force-renderer-accessibility': false,
'ignore-certificate-errors': false,
'allow-insecure-localhost': false,
logsPath: 'C:\\Users\\Dennis\\AppData\\Roaming\\Code\\logs\\20210713T161634'
}
[main 2021-07-13T14:16:34.373Z] Resolving machine identifier...
[main 2021-07-13T14:16:34.373Z] Resolved machine identifier: 79c92c3e31c61cc29cd600c13169fb4e4b470ce2feba0574f1d54b0eca86b50d
[main 2021-07-13T14:16:34.374Z] Main->SharedProcess#connect
[main 2021-07-13T14:16:34.394Z] StorageMainService: creating global storage
[main 2021-07-13T14:16:34.394Z] lifecycle (main): phase changed (value: 2)
[main 2021-07-13T14:16:34.395Z] windowsManager#open
[main 2021-07-13T14:16:34.395Z] windowsManager#open pathsToOpen [
{
backupPath: 'C:\\Users\\Dennis\\AppData\\Roaming\\Code\\Backups\\1626094841957',
remoteAuthority: undefined
}
]
[main 2021-07-13T14:16:34.396Z] IPC Object URL: Registered new channel vscode:877f5a97-b13c-4466-a984-900fbecea355.
[main 2021-07-13T14:16:34.396Z] window#validateWindowState: validating window state on 3 display(s) { mode: 1, x: 448, y: 156, width: 1024, height: 768 }
[main 2021-07-13T14:16:34.396Z] window#validateWindowState: multi-monitor working area { x: 0, y: 0, width: 1920, height: 1040 }
[main 2021-07-13T14:16:34.397Z] window#ctor: using window state { mode: 1, x: 448, y: 156, width: 1024, height: 768 }
[main 2021-07-13T14:16:34.397Z] window: using vscode-file:// protocol and V8 cache options: bypassHeatCheck
[main 2021-07-13T14:16:34.426Z] Setting proxy to '', bypassing '192.168.99.100,<local>'
[main 2021-07-13T14:16:34.441Z] windowsManager#open used window count 1 (workspacesToOpen: 0, foldersToOpen: 0, emptyToRestore: 1, emptyToOpen: 0)
[main 2021-07-13T14:16:34.441Z] lifecycle (main): phase changed (value: 3)
[main 2021-07-13T14:16:34.447Z] update#setState idle
[main 2021-07-13T14:16:34.447Z] resolveShellEnv(): skipped (Windows)
[main 2021-07-13T14:16:34.561Z] [File Watcher (node.js)] [CHANGED] c:\Users\Dennis\AppData\Roaming\Code\User\globalStorage
[main 2021-07-13T14:16:34.565Z] [File Watcher (node.js)] [CHANGED] c:\Users\Dennis\AppData\Roaming\Code\User\globalStorage
[main 2021-07-13T14:16:34.635Z] resolveShellEnv(): skipped (Windows)
[main 2021-07-13T14:16:34.683Z] [File Watcher (node.js)] [CHANGED] c:\Users\Dennis\AppData\Roaming\Code\User\globalStorage
[main 2021-07-13T14:16:34.684Z] [File Watcher (node.js)] [CHANGED] c:\Users\Dennis\AppData\Roaming\Code\User\globalStorage
[main 2021-07-13T14:16:34.899Z] [File Watcher (node.js)] >> normalized [CHANGED] c:\Users\Dennis\AppData\Roaming\Code\User\globalStorage
[main 2021-07-13T14:17:04.458Z] update#checkForUpdates, state = idle
[main 2021-07-13T14:17:04.458Z] update#setState checking for updates
[main 2021-07-13T14:17:04.459Z] RequestService#request https://update.code.visualstudio.com/api/update/win32-x64-user/stable/2d23c42a936db1c7b3b06f918cde29561cc47cd6
[main 2021-07-13T14:17:04.459Z] resolveShellEnv(): skipped (Windows)
[main 2021-07-13T14:17:04.792Z] update#setState idle
Don't worry. I've already faced this problem. This generally appears if your system RAM is mostly occupied i.e many applications are running in the background or some cache. Firstly, restart your system. Open Task Manager and go to the Performance tab and select Memory. If you have very high memory usage, check which application is causing problem i.e using high memory. Google it. If it is a system task, it might be your Antivirus or Windows Defender or some update. In my case, it appears for few minutes and then the main screen and loads. Wait patiently for 5 minutes. My laptop is of 2GB ram only and I'm still able to run VS Code smoothly. If this doesn't work, might be some error in the application itself or some modification made by you. Uninstall VS Code. Since VS code doesn't remove all of its content. You have to do some manual work. Follow this link on How to fully remove VS Code-
https://debug.to/1074/how-to-uninstall-vs-code-completely#:~:text=1%20Go%20to%20Visual%20Studio%20Code%20path.%20%25LocalAppData%25%5CPrograms%5CMicrosoft,the%20.vscode%20folder%20at%20the%20below%20path%20%25UserProfile%25
If you have any problem regarding my answer. let me know in the comments.

WebdriverIO can not create session to test Android emulator with Appium

I am using Visual Studio Code and WDIO with Appium to test Android on emulator by Android Studio, but I can not run Appium for some reason. However Android home and Java home has been set and Appium Doctor confirms necessary dependencies are completed, no fix needed.
I have tried with Appium stand-alone and from Command too.
Wit Appium standalone the ERROR log is the below:
ERROR webdriver: Request failed with status 500 due to session not created: Unable to create session from {
"desiredCapabilities": {
"platformName": "android",
"appium:deviceName": "Pixel",
"appium:platformVersion": "10.0",
"appium:app": "\u002fUsers\u002fzsolt\u002fappium_js\u002fApiDemos-debug.apk"
If I add ['appium'] to services in wdio.config.js the ERROR log is the below, though Appium stand-alone is shut:
ERROR #wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Appium exited before timeout (exit code: 2)
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
at ChildProcess.<anonymous> (C:\Users\zsolt\Documents\AppiumTestProject\node_modules\#wdio\appium-service\build\launcher.js:103:16)
at Object.onceWrapper (events.js:417:26)
at ChildProcess.emit (events.js:310:20)
at ChildProcess.EventEmitter.emit (domain.js:482:12)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
This is my wdio.config.js file with using Appium stand-alone:
exports.config = {
runner: 'local',
port: 4723,
specs: [
'./test/specs/**/*.js'
],
exclude: [
// 'path/to/excluded/files'
],
maxInstances: 10,
capabilities: [{
platformName: 'android',
'appium:deviceName': 'Pixel',
'appium:platformVersion': '10.0',
'appium:app': '/Users/zsolt/appium_js/ApiDemos-debug.apk'
}],
logLevel: 'error',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ['selenium-standalone',
/*['appium', {
//command : 'appium'
}]*/],
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 60000
},
These are my:
"devDependencies": {
"#wdio/local-runner": "^6.1.11",
"#wdio/mocha-framework": "^6.1.8",
"#wdio/selenium-standalone-service": "^6.0.16",
"#wdio/spec-reporter": "^6.1.9",
"#wdio/sync": "^6.1.8",
"appium": "^1.17.1"
Has anybody an idea what am I doing wrong?
Welcome to Stack-overflow!
Below is my configuration and I believe you are missing some important details.
{
platformName: 'Android',
maxInstances: 1,
'appium:deviceName': 'Device Name',
'appium:platformVersion': '8'
'appium:orientation': 'PORTRAIT',
'appium:app': 'Path to App',
'appium:automationName': 'UiAutomator2',
'appium:noReset': true,
'appium:newCommandTimeout': 240,
}
There are boilerplates from maintainers themselves here.
I have played with the boilerplates and was able to run the tests on android emulator through Appium finally.
I have then compared the differences in conf.js and figured out, the below is needed to execute the test.
services:[
[
'appium',
{
// For options see
// https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service
args: {
// For arguments see
// https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service
},
command: 'appium',
},
],
],
Interesting but actually the test runs with only the below capabilites too:
capabilities: [{
platformName: 'Android',
'appium:deviceName': 'Pixel 2',
'appium:app': join(process.cwd(), './ApiDemos/ApiDemos-debug.apk'),
}],
When I execute the test it logs almost the same error messages as before though at the end of the execution it runs the test on the emulator. I did not use the Appium Desktop app.
Not perfect but works...
I guess this issue has been sorted out.
Cheers
Also you need to install the Appium service:
$ npm i #wdio/appium-service --save-dev
Finally check in your wdio.conf.js:
port: 4723, // default appium port
services: [
[
'appium',
{
args: {
},
command: 'appium'
}
]
],
Check that the file you are running is inside the correct folder when you do the 'npx wdio'.
this file

How can I fail Karma tests if there are unhandled rejections?

A couple of places propose this solution:
window.addEventListener('unhandledrejection', function(err) {
window.__karma__.error(err); // yeah private API ¯\_(ツ)_/¯
});
But it throws:
Uncaught TypeError: Cannot read property 'error' of undefined
I'm able to get reports of unhandled rejections with the following setup:
karma.conf.js:
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha'],
files: [
'setup.js',
'test.js',
],
exclude: [],
preprocessors: {},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
});
};
setup.js:
window.addEventListener('unhandledrejection', function(ev) {
window.__karma__.error("unhandled rejection: " + ev.reason.message);
});
test.js:
it("test 1", () => {
Promise.reject(new Error("Q"));
});
it("test 2", (done) => {
setTimeout(done, 1000);
});
Separating setup.js from test.js is not necessary. I just like to have such setup code separate from the tests proper.
When I run karma start --single-run I get:
25 01 2017 07:20:07.521:INFO [karma]: Karma v1.4.0 server started at http://0.0.0.0:9876/
25 01 2017 07:20:07.523:INFO [launcher]: Launching browser Chrome with unlimited concurrency
25 01 2017 07:20:07.528:INFO [launcher]: Starting browser Chrome
25 01 2017 07:20:08.071:INFO [Chrome 55.0.2883 (Linux 0.0.0)]: Connected on socket g-BGwMfQLsQM128IAAAA with id 22107710
Chrome 55.0.2883 (Linux 0.0.0) ERROR
unhandled rejection: Q
Chrome 55.0.2883 (Linux 0.0.0): Executed 1 of 2 ERROR (0.006 secs / 0.001 secs)
Caveat
Reports of unhandled rejections are asynchronous. This has a few consequences.
The example I gave has a 2nd test that takes 1 second to complete. This gives time to the browser to report the unhandled rejection in the 1st test. Without having this delay, Karma terminates without detecting the unhandled rejection.
Another issue is that an unhandled rejection caused by test X may be discovered while test X+1 is running. The runner's report may make it look like X+1 is the test the caused the issue.