Websocket client authetification using python 3.6 and websocket-client

I’m trying to get a websocket client working so I can recieve and store some data from it. In order to get to the websocket on the site you need to be logged in first. Now my question is how can I authentificate to the server and connect to the websocket?

This is the Websocket. I crossed some stuff to avoid missuse.

Google-Chrome-devtools Image

This is what I tried and obviously did not work:

from websocket import create_connection
ws = create_connection("wss://xl2gateway.nti- 
audio.com/XXXXXXXX/websock/netbox_index", header={'sessionid': 'XXXXXXXXXXXXXX'})
result = ws.recv()
print("Received '%s'" % result)
ws.close()

how to run multiple instances/tabs in a single chromedriver instance?

Goal:
open chrome driver
given list of known length urls array, open each url in its own tab and click a counter.
In the urls array list the last url has functionality to go to the page and check the final count.

This is to test websockets, that’s why I want to test it in a single instance.

Current solution:
Have subprocess open with a new instance each time, but this is resource intense.
Trying to lower this resource eating by not opening another instance but rather working in the same instance.

Current solution:
Takes a medium time and most resource usage.

               -> open driver -> go to page -> click counter 
               -> open driver -> go to page -> click counter 
get urls[5] -> -> open driver -> go to page -> click counter 
               -> open driver -> go to page -> click counter 
               -> open driver -> go to page -> click counter 

Wrong solution: takes longest time but least resource usage

open driver -> go to page -> click counter -> open tab -> go to page -> click counter -> 
....

Wanted Solution: (theoretically) should be a little faster if not the same as the current solution, but medium resource usage. (the usage and time cut downs happen because of one less chromedriver instance opening and all tabs processing at the same time.

                              -> open tab -> go to page -> click counter 
                              -> open tab -> go to page -> click counter 
open driver -> get urls[5] -> -> open tab -> go to page -> click counter 
                              -> open tab -> go to page -> click counter 
                              -> open tab -> go to page -> click counter 

So far I have tried implementing this in golang using chromedp, which has hard to read documentation and the library is very unstable.
The other method I have tried is python with chromedriver which is working very well but the issue is of saving as many resources as possible.

thanks a ton for any help toward the right direction!

Opening/Closing headless Chrome with python

I am writing a python script which utilises the Chrome Devtools protocol (I am using the Python wraper PyChromeDevTools headless Chrome, but I need to have an instance of Chrome already running. I would like the script to launch a headless Chrome instance, at the beggining, and close it at the end.

I have tried this:

import subprocess
CHROME_PATH=r'C:Program Files (x86)GoogleChromeApplicationchrome'

chrome_args=[CHROME_PATH,
             '--headless',
             '--disable-gpu',
             '--remote-debugging-port=7912',
             r'https://www.youtube.com/',]

cmd=r" ".join(chrome_args)  

subprocess.call(cmd)

This seems to work (if I navigate to localhost:7912 I see that headless Chrome has started and there is a tab opened with https://www.youtube.com and also a worker pid (which disappears when I kill the python process). But the python script just hangs there, it doesn’t continue to run the rest of the script.

How can I launch headless Chrome so that the script continues. Also, how can I kill this process when I have finished with it?

(If I run the same script, but don’t ask for Chrome to be headless, the script continues as expected).

Python selenium: DevTools listening on ws://127.0.0.1 keeps on popping up

Does anybody have the solution yet? The script was working perfectly fine until yesterday, but suddenly it stopped working. Don’t know why.. 🙁

I tried searching the answer all over Google, but didn’t find yet.
Tried adding options.add_argument(‘–log-level=3’) as well, but no luck.

Can someone help me out with this?

Running Selenium headlessly where you can use extensions

I am able to use headless Chrome and Firefox natively which do not support this though Firefox uses large amounts of CPU. Though no extensions are supported. I find adblock and ghostery to be very crucial. I believe xVfb in linux supports this but cannot find much else on this issue especially as I am a windows user. I have also looked at https://github.com/kybu/headless-selenium-for-win/releases but there is no clarification on this topic.