Now my cypress version is 3.8.2
And when I am opening cypress window there are chrome version is 79.
I want to run my tests in chrome 70 version. I updated my chrome in my computer and now it 70 version.
When I am running my test with selected command
npx vue-cli-service test:e2e --headless --browser chrome
Test is running in Chrome 79. How can I change my chrome version for running.
As per the documentation, the default chrome location to be auto-detected by cypress is "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe". If the other version of chrome is installed in a different location, I guess the available options are to uninstall both 79 & 70 and clean install 70 first to the above said location and later installing 79 to a different location (OR) uninstall 79 (assuming it installed in default location) and re-install to a different location than the default, and finally set a symbolic link to version 70 on the default location something like (which requires admin previleges on the machine, though). This way cypress scans the default location and gets whichever version pointing to the symbolic link.
mklin "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "path to ver70 exe"
But before all, I think the command parameters appear to be slightly off, can you try instead (making sure the path is pointing to the verion 70, not the default one)
npx vue-cli-service test:e2e --headless --browser "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
I suspect --headless is default for a 'cypress run' command command, if your test:e2e is something like "cypress run", then you can simply omit it.
The --browser command supports launching any supported browser by specifying a path to the binary.
So in your case try: npx vue-cli-service test:e2e --headless --browser /usr/bin/chromium
where /usr/bin/chromium is the path for the binary of your needed version of Chrome.
I would like to write a script which run (from the chrome's binary) its lighthouse's audit with a url given.
I didn't manage to find how to do it, but since there is even a chrome extension doing I assume it should be feasible right ?
Google Lighthouse can be ran using the command line. To run it from the command line, you must first install:
Google Chrome for Desktop
Node.js v6 or later.
To install the Lighthouse CLI, open a command line and type the following command:
npm install -g lighthouse
To run an audit with Lighthouse, type:
lighthouse https://example.com
By default, Lighthouse writes the report to an HTML file. You can control the output format by passing flags.
You will notice that a Chrome window is opened every time you run Lighthouse. If you don't want a window to be opened, you can run it in headless mode:
lighthouse https://example.com/ --chrome-flags="--headless"
For the complete list of options, type:
lighthouse --help
Take a look at the Lighthouse source code repository for additional documentation and examples.
You can use/test via npx:
npm i npx -g
Then, directly run from your terminal without using a package.json created or installing globally & without opening a chrome browser instance:
npx lighthouse <URL> --only-categories="performance,seo,Accessibility" --chrome-flags="--headless"
I face the problem with running protractor tests in headless environment. I know about option with Chrome, which implies setting up like that:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu" ]
}
}
However when using this method, I am obliged to have Chrome installed on my system which isn't option for me because I can't be sure about environment which my tests will be run in. PhantomJS would be great in my case, because everything you need is just install npm package. But PhantomJS in deprecated at the moment and can cause some unexpected bugs.
So my question is: Is there any way to use headless Chrome or some other alternative (like PhantomJS) which won't oblige me to install any browser?
Thank you for your time.
I've been looking at the following article about Headless Chrome:
https://developers.google.com/web/updates/2017/04/headless-chrome
I just upgraded Chrome on Windows 10 to version 60, but when I run either of the following commands from the command line, nothing seems to happen:
chrome --headless --disable-gpu --dump-dom https://www.google.com/
chrome --headless --disable-gpu --print-to-pdf https://www.google.com/
And I'm running all of these commands from the following path (the default installation path for Chrome on Windows):
C:\Program Files (x86)\Google\Chrome\Application\
When I run the commands, something seems to process for a second, but I don't actually see anything. What am I doing wrong?
Thanks.
Edit:
As noted by Mark Rajcok, if you add --enable-logging to the --dump-dom command, it works. Also, the --print-to-pdf command works as well in Chrome 61.0.3163.79, but you'll probably have to specify a different path for the output file in order to have the necessary permissions to save it.
As such, the following two commands worked for me:
"C:\Program Files (x86)\Google\Chrome\Application\chrome" --headless --disable-gpu --enable-logging --dump-dom https://www.google.com/
"C:\Program Files (x86)\Google\Chrome\Application\chrome" --headless --disable-gpu --print-to-pdf=D:\output.pdf https://www.google.com/
I guess the next step is being able to step through the dumped DOM like PhantomJS with DOM selectors and whatnot, but I suppose that's a separate question.
Edit #2:
For what it's worth, I recently came across a Node API for Headless Chrome called Puppeteer (https://github.com/GoogleChrome/puppeteer), which is really easy to use and delivers all the power of Headless Chrome. If you're looking for an easy way to use Headless Chrome, I highly recommend it.
This works for me:
start chrome --enable-logging --headless --disable-gpu --print-to-pdf=c:\misc\output.pdf https://www.google.com/
... but only with "start chrome" and "--enable-logging" and with a path (for the pdf) specified - and if the folder "misc" exists on the c-directory.
Addition: ... the path for the pdf - "c:\misc" above - can of course be replaced with any other folder/dir.
With Chrome 61.0.3163.79, if I add --enable-logging then --dump-dom produces output:
> "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --enable-logging --headless --disable-gpu --dump-dom https://www.chromestatus.com
<body class="loading" data-path="/features">
<app-drawer-layout fullbleed="">
...
</script>
</body>
If you want to programatically control headless Chrome, here's one way to do it with Python3 and Selenium:
In an Admin cmd window, install Selenium for Python:
C:\Users\Mark> pip install -U selenium
Download ChromeDriver v2.32 and extract it. I put the chromedriver.exe in C:\Users\Mark, which is where I put this headless.py Python script:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("headless") # remove this line if you want to see the browser popup
driver = webdriver.Chrome(chrome_options = options)
driver.get('https://www.google.com/')
print(driver.page_source)
driver.quit() # don't miss this, or chromedriver.exe will keep running!
Run it in a normal cmd window:
C:\Users\Mark> python headless.py
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" ...
... lots and lots of stuff here ...
...</body></html>
Current versions (68-70) seem to require --no-sandbox in order to run, without it they do absolutely nothing and hang in the background.
The full commands I use are:
chrome --headless --user-data-dir=tmp --no-sandbox --enable-logging --dump-dom https://www.google.com/ > file.html
chrome --headless --user-data-dir=tmp --no-sandbox --print-to-pdf=whatever.pdf https://www.google.com/
Using --no-sandbox is a pretty bad idea and you should use this only for websites you trust, but sadly it's the only way of making it work at all.
--user-data-dir=... uses the specified directory instead of the default one, which is likely already in use by your regular browser.
However, if you're trying to make a PDF from HTML, then this is fairly useless, since you can't remove header and footer (containing text like file:///...) and the only viable solution is to use Puppeteer.
You should be good. Check under the Chrome Version directory
C:\Program Files (x86)\Google\Chrome\Application\60.0.3112.78
For the command
chrome --headless --disable-gpu --print-to-pdf https://www.google.com/
C:\Program Files (x86)\Google\Chrome\Application\60.0.3112.78\output.pdf
Edit:
Still execute commands where the chrome executable is, in this instance
C:\Program Files (x86)\Google\Chrome\Application\
I know this question is for Windows, but since Google gives this post as the first search result, here's what works on Mac:
Mac OS X
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --dump-dom 'http://www.google.com'
Note you MUST put the http or it won't work.
Further tips
To indent the html (which is highly desirable in real pages that are bloated), use tidy:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --dump-dom 'http://www.google.com' | tidy
You can get tidy with:
brew install tidy
If you want to dodge on the problem in general, and just use a service of some kind to do the work for you, I'm the author/founder of browserless which attempts to tackle running headless Chrome in a service-like fashion. Other than that it's pretty tough to keep up with the changes and making sure all the appropriate packages and resources are installed to get Chrome running, but definitely doable.
I solved it by running this (inside chrome.exe directory),
start-process chrome -ArgumentList "--enable-logging --headless --disable-gpu --print-to-pdf=c:\users\output.pdf https://www.google.com/"
you can choose your own path.print-to-pdf=<<custom path>>
I need help getting the SublimeLinter to work.
I have installed the SublimeLinter using the package installer. However I cant see the lint working in my js files. Also when I do command + shift + P (linux) I only see the following command for linter 'Sublime Linter : Extract Annotations'.
I don't see the other commands for running the linter.
Any Ideas what is wrong?
Thanks,
Murtaza
You have to install nodejs from the repos.
If nodejs isn't installed in /usr/local/bin/node you have to set a symbolic link to this place:
touch /usr/local/bin/node
ln -s /usr/bin/nodejs /usr/local/bin/node
The above worked for me on debian/crunchbang
Alternatively you can change the sublime user settings for linter(ps haven't tested this option)
"sublimelinter_executable_map":
{
"javascript": "/usr/bin/nodejs"
}
Some tips:
Be sure your files are using the Javascript syntax.
The linter runs automatically (check the package settings).
Open the console to see any errors.
Check the documentation to configure Javascript linters