I am unable to execute scripts on saucelabs via my local machine as we are not able to create webdriver session and it returns status 401
I have tried the following :
Changed the path of chrome.exe file as it looks for the file in default path
"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
Also tried adding this to config :
karate.configure('driver', { type: 'chrome', port: 9222, executable: 'C://Program Files//Google//Chrome//Application//chrome.exe' });
None of the above works !
curled the following commands which didnt work
curl -v --proxy http://proxyHost:80 https://ondemand.us-west-1.saucelabs.com/wd/hub/status
curl -v --proxy https://user:password#proxyHost:proxyPort https://ondemand.us-west-1.saucelabs.com:443/wd/hub/status
Finally tried this :
URL https://ondemand.us-west-1.saucelabs.com/wd/hub/status in a browser and got the below :
{"ready":true,"message":"Sauce Labs automated testing is fully operational"}
update: I do see a tunnel provisioned on sauce labs. However, the browser won't launch as it's not able to create a chrome web driver session
As Peter mentioned, chrome.exe will not come into play here as that is only for local execution. Please see the following repo that has a working example of Karate working with Sauce Labs execution: Karate/Sauce Labs GitHub example
I'm new to angular and i have a problem with angular and xampp. I'm trying to load images from mySQL database where i stored their destination. Problem is that angular tries to access that destination through this:
My HTML is:
But my url to that image is without port :4200
When i access localhost/bcPraca/php/upload/imageName then that image shows up so it works.
So how can i remove that port from Url. Or what can i do to make it work ?
Everything else is working properly except that source in the image.
You have to use a proxy in order to be able to communicate with your backend/
In order to use a proxy:
Create a proxy.conf.json in the root of your workspace (adapt the following to our needs):
{
"/api": {
"target": "http://localhost/api",
"secure": false,
"changeOrigin": true
"logLevel": "debug"
}
}
Start your app with the following command:
ng serve --proxy-config proxy.conf.json
You can read more about angular proxy here
You Can put prefix like http:// Before Your Image Source And It Will Work
so i'm trying to follow this tutorial for Registration : https://reactnativecode.com/react-native-user-registration-example-tutorial/#comment-878
i’m using WampServer on Windows 10. I did as mentioned.
I created a folder called “/react” under “C:\wamp64\www\react” and put the two .php files there .
when i put “localhost/react” in my browser i can see the .php files .
i changed the URL to : ‘http://localhost/react/user_registration.php’
But i’m still getting that error .. i’m not sure what i’m doing wrong here
This happens simply because react-native consider localhost as an URL but it doesn't have a domain :
Solution
On Windows =>
Run [Ctrl] + R
Then type : "cmd", press enter
write "ipconfig" then press enter
a list of IP configurations will show, copy the IP address besides "IPv4 Address", it's under "Ethernet adapter VirtualBox Host-Only Network #2:", it starts with 192.168.xxx.x
on MAC =>
http://osxdaily.com/2010/11/21/find-ip-address-mac/
You will now need to replace the URL with this IP Address
you will have this at the end : ‘http://192.168.xxx.x/react/user_registration.php’
as you've seen, i have replaced localhost to the ip address taken from the CMD [i.e IPV4 Address]
You can also use only free hosting website like Awardspace, 000Webhost to test your app on a real device. Use your local server or this ip address, you can't fetch the data from real device
Hope this will help you!
Franz
I use XAMPP as an Apache Server and as described here https://www.browsersync.io/docs/options#option-proxy
i do the following in gulp:
browserSync.init({
proxy: "localhost/mysite.de/DEV_F3/public_html",
});
But BS opens my browser at "localhost:3000/mysite.de/DEV_F3/public_html" which gives me a 404.
Why does it add that port 3000 and how do I get this to simply work?
For your gulpfile.js you may change the following line to include your XAMPP port:
browserSync.init({
proxy: "localhost/mysite.de/DEV_F3/public_html",
port: 8000
});
so that when gulp initiates, it will run
localhost:8000/mysite.de/DEV_F3/public_html in the browser instead of
localhost:3000/mysite.de/DEV_F3/public_html
Note: The port is either 8000 or 8080, depending on your config.
Hope it helps
Check your Xampp port, because if for some reason you have changed the default Xampp port, you need to put the new port of your Xampp. Another part that you can check is also your Virtual Hosts and Hosts this if you are using Windows OS.
Directories:
C:\xampp\apache\conf\extra -> httpd-vhosts.conf
C:\Windows\System32\drivers\etc -> hots
After checking these settings you can use browsersync following the official documentation.
Come on, go to your gulpfile.js
browserSync.init({
proxy: "localhost:8080/mysite.de/DEV_F3/public_html",
});
When running your on your terminal you will have this return on your browser
gulp watch
Location:
Local:http://localhost:3000/mysite.de/DEV_F3/public_html
I hope it has helped or directed you to a greater understanding.
Try using
browserSync.init({
proxy: "localhost/mysite.de"
online: true
});
This is assuming that 'mysite.de' is the root directory of your site.
The 'online' part supposedly helps with performance.
I've been trying to run my tests using karma-chrome-launcher, but everytime I run my tests it throws this error:
INFO [launcher]: Starting browser Chrome
ERROR [launcher]: Cannot start Chrome
INFO [launcher]: Trying to start Chrome again (1/2).
ERROR [launcher]: Cannot start Chrome
INFO [launcher]: Trying to start Chrome again (2/2).
ERROR [launcher]: Cannot start Chrome
ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.
Here's my karma.conf.js code:
// Karma configuration
// Generated on Mon Mar 23 2015 14:04:19 GMT-0300 (BRT)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: 'www',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'lib/ionic/js/angular/angular.js',
'lib/ionic/js/angular/angular-animate.js',
'lib/ionic/js/angular/angular-sanitize.js',
'../node_modules/jasmine-core/lib/jasmine-core/jasmine.js',
'../node_modules/mock-local-storage/lib/mock-localstorage.js',
'../node_modules/angular-mocks/angular-mocks.js',
//'../node_modules/requirejs/require.js',
'lib/ionic/js/angular/angular-resource.js',
'lib/ionic/js/angular-ui/angular-ui-router.js',
'lib/ionic/js/ionic.js',
'lib/ionic/js/ionic-angular.js',
/*'../tests/libs/ngCordovaMocks.min.js',*/
'js/lib/ng-cordova.min.js',
'js/*.js',
'js/controllers/*.js',
'js/services/*.js',
'js/factory/*.js',
//'../tests/*.js',
'../tests/**/*.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'html'],
htmlReporter: {
outputFile: '../tests/report/index.html'
},
// web server port
port: 9876,
plugins : [
'karma-junit-reporter',
'karma-jasmine',
'karma-phantomjs-launcher',
'karma-chrome-launcher'
//'karma-htmlfile-reporter'
],
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
I'm installing the module here: https://www.npmjs.com/package/karma-chrome-launcher
Thanks!
I had the same problem and tried a lot of the suggested solutions I found, but what finally solved it for me was to delete the node_modules folder and getting everything new via npm install.
Had the same issue with my build environment.
What i did is to follow the advice of Rafael Cichocki to enable the debugging:
logLevel: config.LOG_DEBUG
Then tried to launch the chrome-browser with exactly the same line that was visible int he debug output.
Turned out that chrome browser was crashing due to missing ttf fonts. So running:
apt-get install ttf-freefont
Solved that issue for me and karma started to launch chrome.
In Karma.conf.js, Increase timeouts to 60000
captureTimeout: 60000,
browserDisconnectTimeout: 60000,
browserDisconnectTolerance: 3,
browserNoActivityTimeout: 60000,
browsers: ['PhantomJS'], Here allowed browser is PhantomJs, but code is trying for Chrome, which is not a specified browser in the karma.conf.js.
Change karma.conf.js file :
browsers: ['PhantomJS','Chrome', 'ChromeHeadless'],
chrome- is for opening new chrome browser window.
ChromeHeadless- is for running tests without opening browser window
make sure Chrome is installed and added to PATH
Hope this helps
I noticed when I had this error that when I changed the spec file and saved it, it seemed to work again. I had a few errors in typescript that didn't break the tests (passing in null arguments to a virtual component instance constructor). I don't know if it was resolving the errors since they existed before when it was working, or if changing the file and saving it updated the cache.
So this could mean that clearing the cache in Chrome could also potentially resolve it. It's working now again for me so I can't check to verify.
Just in case you are running this behind a corporate proxy. Make sure you include your 0.0.0.0 in your NO_PROXY Environment variable.
Otherwise your test will first go out through your firewall where it will most likely not be able to reach 0.0.0.0. So just to be sure I include the following in my
NO_PROXY=127.0.0.1,localhost,0.0.0.0
Especially if you are running your tests in a container environment (e.g. your build pipeline) non set environment variables might be a common reason for ng test working fine on your local machine but failing to connect to google-chrome in the container.
If someone faces this error only in gitlab-runner (but in shell by hand ng test work ok), you can apply decision from here:
https://forum.gitlab.com/t/running-karma-tests-with-chrome-and-gitlab-ci/14476
The decision is: in karma.config.js, replace the section
browsers: ['Chrome'],
by
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
The reason of error is that Chrome doesn't support no-sandbox anymore
I got my inspiration partially from here: https://stackoverflow.com/a/33802985/1534823
Also use logLevel: config.LOG_DEBUG - it can help you get good information on what is causing your error`
Check following settings in karma.conf:
captureTimeout: 60000,
browserNoActivityTimeout: 360000
browser: ["Firefox"]
captureTimeout - your browser may take some time to start. LOG_DEBUG should show some error related to capturing your browser
browserNoActivityTimeout - PhantomJS is really slow(x10) on my machine, in comparison to Firefox and Chrome. Karma may timeout before your tests complete.
browser - our jenkins server runs on linux, where we had no binaries for chrome, so we had to switch to firefox
If any of these three settings were not set correctly, we would get the error you described above.
I was able to resolve this by remove the absolute path (src/examplePath) and changing it to a relative path (../../examplePath).
Example change in spec:
import { myPackage } from 'src/myPath'; (seems to be the issues)
import { myPackage } from '../../../myPath'; (seems to resolve it)
Note I had tried deleting the node modules and npm installing but that didn't work. I'm so not sure why this matters.
In Windows Chrome was install to %LOCALAPPDATA%/Google/Chrome/Application earlier. Now it's install to %PROGRAMFILES%/Google/Chrome/Application. If you is very long time with Chrome then your have old version in %LOCALAPPDATA%/Google/Chrome/Application.
Karma-launcher is searches Chrome location in order LOCALAPPDATA->PROGRAMFILES-> 'PROGRAMFILES(X86)' , first found old version and try to run it.
Just delete %LOCALAPPDATA%/Google/Chrome/Application folder
Solution for us with angular cli was setting the following properties in the karma.conf.js
autoWatch: false,
singleRun: true
I was also facing this issue. I made below three changes in my karma.config.js file.
autoWatch: false,
browsers: ['Chrome'],
singleRun: false
I experienced this after updating macOS to Catalina. I solved it by updating Puppeteer to the latest version.
What worked for me:
npm un karma-chrome-launcher
npm i karma-chrome-launcher
npm i -g karma-cli
karma init (and follow the prompts)
ng test --watch=false
Using the watch flag set to false in combination with adjustment of the following parameters in karma.config.js worked for me:
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
I faced a similar issue recently.
And found two solutions to fix this problem.
I installed puppeteer and added process.env.CHROME_BIN = require('puppeteer').executablePath() at the top of my karma.conf.js file, as documented here.
I uninstalled Google Chrome and cleared up all the system folders (%Local Appdata%\Google and also from Program Files / Program Files x86), restarted by the system, and then installed Chrome x64 from the official site.
I was happy with the 1st solution as well, but since I wanted to fix the root problem, I went ahead and found the second solution as well.
Hope this solves the problem for anyone facing this issue.