How do I use Safari as my browser for debugging when using Visual Studio Code running an Angular app? - visual-studio-code

I have an Angular app (.Net Core backend). I can create configurations in the launch.json file and debug with Firefox, Chrome, Edge, etc. But I don't see any option for Safari!
QUESTION - How do I create a configuration for Safari to use instead of Chrome when launching the debugger? When I click 'add configuration' in launch.json, which option do I select for Safari? Do I need a separate extension?

I found some links for you:
https://stackoverflow.com/a/51738121
https://stackoverflow.com/a/66942204
Set the BROWSER environment variable before executing the start command may help.
This environment variable is documented here: https://create-react-app.dev/docs/advanced-configuration/
By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a browser to override this behavior, or set it to none to disable it completely. If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to npm start will also be passed to this script, and the url where your app is served will be the last argument. Your script's file name must have the .js extension.

Related

How to make firefox developer edition as default browser for development [duplicate]

I am setting up my VS Code environment for the first time, but I can't figure out how to set Chrome as the default browser for the workspace.
Go to file-> preferences -> user settings -> search "By Default it will open your default favorite browser" set your browser.
The other StackOverflow questions regarding the browser, had to do with opening a specific file. Here are the steps to creating a tasks.json file in a brand new environment.
From the Tasks menu, Select 'Configure Tasks'
The entry field prompts you for 'Select a task to configure'
Choose 'Create tasks.json file from template'
Edit the file to include the following block:
{
"version": "0.1.0",
"command": "Chrome",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"args": ["${file}"]
}
Chrome can be launched by way of debugging your application. Within launch.json, the configurations[].serverReadyAction.action configuration was given a possible value of debugWithChrome in the VS Code February 2019 release. Note that this will also require you have the Debugger for Chrome extension installed. You will not receive a warning if the extension is not installed and you've configured launch.json to use debugWithChrome.
Note: Configuring launch.json with debugWithChrome will work even if you launch using CTRL+F5 to run the app without debugging.
Go to Settings -> Extensions -> Live Server Config -> Update Default Browser:
This Alternate Way helped me:)
GoTo-->Google Chrome-->Settings-->Default browser-->Set Google Chrome as default browser
The method of modifying tasks.json no longer works in newer versions of Visual Studio Code. The easiest way to be able to launch your code in a browser is to install the Open in Browser extension from the marketplace.
After it is installed and VS Code is reloaded, you can go to your code and press ALT + B to launch your application in your default browser or ALT + SHIFT + B to select the browser you want to use.
You can also right click and select these option from a drop down menu, but I mention this last because this currently does not work in some versions of VS Code.
Just a helper for the windows users, I just installed windows 10 again and I was wondering how do I set my vscode to open the server (web) using chrome instead of edge, so to do that you just have to configure your windows to use google chrome as default, you don't need to change anything in vscode, I hope this helps someone.
ps: normally you can go open browser you want to be default and setup the configuration. so in chrome you have to go to configurations and scroll down to default browser.
When you want to use your own browser using "Open with Live Server" without change OS globally configuration.
In Windows, Visual Studio Code (ver. 1.70.1 (July 2022)). Go to "File" > "Preferences" > "Settings"
Then select a tab, "User" tab if you want your desired browser for all your projects, or select "Workspace" tab or "ProjectName" tab for especified projects.
Then go to "Extensions" > "Live Server Config" > "Settings: Custom Browser" finally change the 'null' value selecting the browser of your preference from the list (apparently this list depends on installed browsers but i'm not sure).
search for local.testsettings on vscode on the search and for web tests, change the browser to chrome and apply.
The Live Server extension was not appearing for me on settings. However, I installed Open in Browser and typed "liveServer.settings.CustomBrowser" in settings and the extension appeared with a dropdown box in which I was able to change the default browser.
Hope this helps!
This may be old but I found something that could help.
First go to Settings/Apps/Default Apps. Set your browser as default.
Next go to VSCODE and go to File/Preferences/Settings/Extensions/LiveServerConfig
Then scroll to settings: CustomBrowser
Change it to your custom browser
Note- If the browsers don't show up on VSCODE then you need to set it to default in the settings.
You can adjust settings in your computer to open.HTML file extensions in chrome as a default browser:
for Example in PC windows:
go to Control Panel > Default programs > Associate a file type or protocol with a specific programs >HTML extension and choose Chrome.
In my case changing the default browser in the system settings of my pc did it.
None of the above works in my case(my version is August 2022 1.71) to make it work I went straight to **
File-->Preferences-->Settings-->Extensions-->Plugin open-in browser
** from there was a option which says Default set browser so I choose Brave as there is no ads in it while playing the video as chrome plays ads so for getting a proper feeling of using my self made Jarvis I used Brave.
Thanks
Click settings -> enter: default browser -> find: Open-in-browser:Default -> enter: Google Chrome
Google Chrome > Settings (left sidebar) > Default browser = Google Chrome
Just change your default web browser in your OS.
In Windows 10, you can search "default browser" then the wizard for changing it, will be appear.

Open Angular project with different browser?

Is there a way to open up an Angular project with a different browser than the default one?
Currently I need IE as default, but I want to open Angular projects with Chrome. Something easy from the terminal (like ng s -o -browser chrome)?
There is not such thing!!!
However, you can configure the debug section (as explained in links below) to open the app in chrome, edge or firefox.
Both, ng serve and vscode(debug mode), you can achieve something similar.
See this links:
https://www.youtube.com/watch?v=57lzJmGR8U8&ab_channel=Pixelpro
https://code.visualstudio.com/docs/editor/debugging
Try:
ng serve --browser to open the default browser
ng serve --browser=firefox to open a specific browser
You can check it from here.

setting breakpoint angular cli .spec.ts code for debugging

I'm using angular2 cli and am following the test debugging instructions here official documentation. I'm able to search for the spec.ts source files which are in the app folder and set break points. However, I'm not able to do the same for the test files for components in other folder. The tests do run but I'm not able to find the source file in the chrome browser. Shall I edit some config file? I've tried to add the source files manually to the source in chrome but that doesn't help in setting the breakpoint. Any help is very much appreciated.
Do this and see what happens:
In a test that you cannot find, add a debugger; statement
Run ng test
When Karma is loaded in a new browser window, click the "Debug" button
Open the developer tools as soon as a new tab is opened in Chrome (reload the tab if you do this late)
See the "Source" devtools tab open to the file and break on the debugger statement. This should be the answer to your question.

When launching google apps from command line , don't want to open google chrome browser

When I launch google apps[which is developed by myself] from command line, for example:
chrome.exe --load-and-launch-app="C:\Users\KyawKhaing\Desktop\chrome\Chrome App\Example2"
After I run this, I see Google Chrome Browser open first follow by my google chrome apps launch. I don't want to open google chrome browser when I launch a chrome app. Any one know the solution. Is it possible?
Use the --silent-launch argument.
chrome.exe --silent-launch --load-and-launch-app="C:\Users\KyawKhaing\Desktop\chrome\Chrome App\Example2"
As I was running automation scripts in java, i did notice that chrome did not open using command prompt.
Runtime.getRuntime().exec("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe \"http:\\www.google.com\"");
From Windows 7, I fixed the problem with the following steps:
Go to the folder C:\Program Files (x86)\Google\Chrome\Application
Right-click on chrome.exe
Select Properties
Select the Compatibility TAB
Click on the "Change settings for all users" button
Make sure to put a Check Mark on "Run this program in compatibility mode for:" and
Select "Windows 7" from the drop down list.
Enjoy!
I don't think you can do it currently. It is a reasonable feature request! You can make feature requests at http://crbug.com/new
There is a bug already logged for this, see http://crbug.com/175381.
We are working on making app background pages keep the browser process alive; once this is done we can fix this bug. The problem currently is due to the way the process is kept alive - if we don't show the browser window the process exits between loading the app and the app opening a window.
I don't think you can do that. The browser is the environment of the app. Its like trying to run a windows app, without running windows. The app depends on the browser. You can't open the app without opening the browser first. Sorry. Hope this helps.

Is there a way to add Google Chrome as an external web browser in Flash Builder Standalone for Mac?

It currently seems impossible to add Google Chrome as an external web browser in Flash Builder Standalone for Mac. In this context, Eclipse only cares about "Unix executables" and not .app files.
For example, the path to Firefox on a Mac is: /Applications/Firefox.app/Contents/MacOS/firefox-bin
which is only found by right-clicking and choosing 'Show Package Contents' on Firefox.app in your Applications directory.
If you try to add Google Chrome as a new external web browser, you'll have to repeat this process to navigate to /Applications/Google Chrome.app/Contents/MacOS where the 'Google Chrome' Unix exxecutable resides.
The problem is that space in the name. If you attempt to click OK in Eclipse, you'll get an error preventing you from continuing:
The location value is not a valid path
name
Are there any workarounds for this so I can use Chrome as my development browser only? I did some searching and all I could come up with was this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=297273
UPDATE: A kind and savvy Flash Builder engineer gave me a helpful tip. Note that you'll need to show hidden files in Mac, by opening Terminal and entering the following command:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Press Return to relaunch Finder. Once hidden files are shown, "You’ll find what you need in [YOUR WORKSPACE]/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.browser.prefs.
There’s a 'browsers' property there that defines XML for defining Eclipse’s web browsers. Add a new browser location and name and restart Flash Builder."
In this case you'd add:
<external location\="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" name\="Google Chrome"/>\n
I can confirm that this works. Hopefully we won't have to resort to this kind of hackery on the next go around.
You can do this from the UI in FB 4.5 - However, you need this exact path (unquoted and unescaped) in Preferences->Web Browser. Select "Use External Browser" and add the line below as the location (You may not need the 'name\="Google Chrome" bit, but looks like it worked all in one line for me):
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" name\="Google Chrome
You could create an executable here: /usr/local/bin/chrome with these contents:
#!/bin/sh
open -a 'Google Chrome' $1 &
And then ensure Chrome's Preferences settings for "Web Browser" are this for external web browser "Google Chrome":
Name: Google Chrome
Location: /usr/local/bin/chrome
Parameters: %URL%
Update
As of Eclipse 4.3.1, the script approach (below) no longer works, but the simpler option of simply selecting "Google Chrome.app" as an external browser (using Eclipse UI) is fixed.
Old (obsolete) answer
My workaround was to create a shell script that opens Chrome (see below), and point Eclipse to this script. In this way Chrome is opened with 2 tabs - the home page and the requested page - but this was good enough for me.
#! /bin/sh
open /Applications/Google\ Chrome.app $*
You need the path to the Unix Executable file of Google Chrome.
How to:
in Finder, right click Google Chrome.app "Show Package Content".
Navigate down to Content/MacOS
cmd + i and copy the path to the Unix Executable File
In Eclipse Preferences Web Browser / Location, "brows.."
Paste in the path to the Unix Executable.
The path, something like: /Applications/Google Chrome.app/Contents/MacOS
Location: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Parameters: -sandbox
The simplest way to get Flash Builder Standalone for Mac to recognize Chrome as the default system browser is
Open Safari
Go to menu Safari > Preference > General
Change 'Default web browser' : Safari
Change 'Default web browser' : Chrome
Close Safari
This solution is more general as it applies to any application which chooses the incorrect system browser. (thanks to Kelvin Lawrence at IBM)
For me worked with the following configuration:
Location: /usr/bin/open
Parameters: -a "Google Chrome.app" %URL%
I found the solution in a blog's post that doesn't exist anymore, it involves configuring the Location to be /usr/bin/open and the parameter is %URL%.
You need to make sure that google chrome is your default browser and it will work properly. This is the only method that worked for me on OSX Lion.
/Applications/Google\ Chrome.app/Contents/MacOS
escape the space in the path to the google chrome executable. OS X only cares about unix executables, because its posix based as well, it doesn't actually have much to do with eclipse.