I am writing a test on Selenium Webdriver. But the tricky part is, I need to send headers to the Chrome while working. Actually, I am adding a chrome extension to change the headers on runtime. But the most tricky part is that my test is running on Browserstack. Does my extension apply on browserstack too?
Yes, you can add extensions on BrowserStack Automate.
You need to upload the extension using ChromeOptions. But you need to have the .crx file on your local machine. You can refer to the below Python snippet and port it to the language of your choice. This would enable you to use the extensions on BrowserStack.
chrome_options = Options()
chrome_options.add_extension('/Users/ABCD/Downloads/Adblock-Plus_v1.12.4.crx')
desired_cap = chrome_options.to_capabilities()
Related
I've developed a chrome extension and I would like to e2e test it in a pipeline. So I install Cypress. But then I saw the following code example
// NOTE: extensions cannot be loaded in headless Chrome
It states that it is not possible to load an extension in headless mode. Why is this the case, I assume that there is a good reason for this.
SOURCE
I have written a python program to download YouTube videos. I want to add it as an extension to browser, but I have read that browser doesn't run python scripts. So how can I deploy it? Can I convert it into a software which when installed can be added as a plug-in to the browser? Or is there any other way of doing it?
I assume you are aware of the chrome extension/plugin development, If not, please go through online tutorials, Fast forward...
Adding Python to the Chrome extension
We have two options to add Python into a chrome extension:
Method 1: Include
Brython
in an iframe (requires server)
To run Python in the browser you have several options including Brython and emcascripten.
Method 2: Compile Python to Javascript using
Rapydscript
(best, serverless, pure extension.)
There are several tools to compile Python to Javascript. Rapydscript works fine, Pyjs does not work well with chrome.
Further, you can do your research.
I just started developing my first Chrome extension.
Tutorials describe the process like this:
put code in a folder
load it into Chrome using Settings | Extensions
run it & use Chrome devtools to set breakpoints.
However, this seems like an extremely tedious process. I use WebStorm and would much rather start the debugging session from there and also set breakpoints in WebStorm.
I am sure there must be an option and developers do not manually load the extension in chrome after every change.
I am new to Firefox and Chrome extension development.
I have downloaded and tested helloworld sample extension in both FF and Chrome in development mode.
Followed the following steps to work properly in FF and chrome,
In FF
Extracted the sample extension, and added one file in /mozilla/firefox/dev_user/helloworld#mozilla.doslash.org and given extracted folder path.
My FF version is 12.0 and I changed the<em:maxVersion> to 12.0.* in install.rdf file.
Restarted FF and tested, it worked fine.
In Chrome:
Extracted the sample extension
Choose Tools > Extensions
Checked Developer mode
Click the Load unpacked extension button
Dialog appears and selected extracted sample extension folder path
Extension is added and works perfectly.
Now I would like to know how to package these extensions? I mean on clicking the package that extension should install directly in the browser instead of following the above steps.
It's generally not a good idea to ask four questions at once. Let's try to answer all your questions:
How do I package a Firefox extension?
You follow the official documentation (a Firefox XPI package is simply a ZIP archive).
How do I package a Chrome extension?
You follow the official documentation.
How do I make sure a Firefox extension can be installed from a website?
That question is already answered elsewhere.
How do I make sure a Chrome extension can be installed from a website?
You cannot. Current Chrome versions make it very complicated to install extensions from third-party sites. Your best bet is to upload your extension to the Chrome Web Store (as a ZIP archive of extension files, not a proper package - Chrome Web Store creates the package for you). Once the extension is in the Chrome Web Store you can use inline installation to simplify installation from the website associated with your extension.
I need to run Selenium (or another webscraping tool that can handle javascript) on a remote linux host (Webfaction). I am using Python.
Is this possible? The server is gui-less so I can't run browsers. Or can I, if I use PyVirtualDisplay?
What about running Selenium with HtmlUnit?
I have tried using Selenium with Selenium/PyVirtualDisplay/ChromeDriver, but keep getting various error messages. So I'm wondering if this is even possible before I continue to debug something impossible.
If you need to handle JavaScript Selenium/Webdriver seems to be a good solution.
If you need to run headless, GhostDriver (instead of ChromeDriver) is an excellent alternative. It is based on PhantomJS, a headless browser based itself on Webkit. It has full JS-support.