How to control native chrome with selenium web browser - python

I want to run the default browser, which we normally use for browsing.
I wouldn't want to run it with chrome webdriver.
it would be like opening the default browser pages "Chrome.exe" and not "Chromedriver.exe"
It's possible?

Yes, it is possible. You should learn Chrome DevTool Protocol(CDB). More details are here
It is low-level browser communication protocol. It communicates via WebSocket and you need to learn how to program WS and read CDP API.
Puppeter working in that way, directly communicate with Chrome.
Logic of Webdriver is to standartize some commands across all browsers.
Similarly, Firefox has Gecko protocol.

Related

Python Selenium: Proxy authentication in Headless mode

Following this question, I know how to authenticate the proxy. This method is like using an extension to control the authentication. And to use the extension, the browser must be shown up.
My question is: How can I authenticate the proxy without an open browser (headless mode), using selenium and chromewebdriver?
I tried with using google chrome flags. But cannot find the solution.

set system vpn (pptp vpn) in selenium headless option

I have a system VPN (I am using pptp protocol) and I am going to use Selenium to test our website, but since only internal users are able to access that website without using a VPN, I cannot access the website to test. When I am using Selenium in GUI mode (not headless) it works fine without any problems but when I switch to headless mode using this command:
chrome_options = Options()
chrome_options.add_argument("--headless")
I get an error because my VPN does not work in the headless mode. Is there any way to use and set my VPN in headless mode in Selenium?

Can Playwright be used to launch a browser instance

I'm finding that in some cases web pages are being rendered in one browser materially different than another browser. Specifically, Playwright running webkit is rendering a different structure than what I see when viewing the page in a standalone Chrome browser. No clue why and I can't do anything about it. This isn't a Playwright issue, it is rendering it the same way as a standalone browser would. Problem is I don't know of an up-to-date webkit based browser for Windows.
Is there a way using just Playwright to open a browser window that will let me manually enter a url and inspect the page as Playwright renders it?
You can use Playwright's codegen tool and open the webkit browser
playwright codegen -b webkit
In playwright.config you have option
channnel: "chrome"
So with this you will start chrome, not chromium driver.
You can also use the following command to launch a webkit browser with a desktop safari user agent:
npx playwright codegen -b webkit --device "Desktop Safari"

How to add a proxy with authentication for chrome selenium in python

I'm using selenium 3.141.0 with python 3.9 and chrome webdriver, I've managed to make my bot do the actions I require on the pages, but I can't find a way to make it work with a proxy.(For the proxy I'm using NORDVPN)
Until now I tried a class that creates a manifest_json and a background.js and archives them so it uses them as an addon, and I get multiple errors depending on the port I use:
tunneling error, page refused to send data or time out

Python Selenium - Proxy with authentication on headless mode

I need to run proxies that requires authentication on selenium in headless mode.
I think many people are aware of the answer given on this post and it does work very well honestly But only In NON Headless Mode. As extensions are no longer supported in headless mode how to set proxy with authentication in selenium chromedriver python?
Besides that method, another very good method to run proxies that works in headless mode is by using the module selenium-wire. However, selenium-wire can only run in HTTP. To run HTTPS you would need to import a generated certificate into google chrome. So you cant run HTTPS programmatically.
Is there any good options to run proxies with authentication in headless mode? I'm sure many of us are wondering the same thing.
Thanks!

Categories

Resources