How to pull up Chrome Console in Visual Studio Code - visual-studio-code

I have 2 questions about the same thing please ;)
I am developing an extension for Code and I need to see the Chrime console. Therefore:
How can I pull up Chrome Console to see the Console messages coming from my extension
How can I pull up a Chrome Console for the HTML content that I and displaying in my extension via DocumentProvider?
The question 2 is there as I happened to visualize the Console after some exception but I could not access the HTML and JS content of the extension generated page.

See Help -> Toggle Developer Tools.

Related

Testing browser devtools extension with puppeteer

I'm currently looking for a way to run automated tests on my devtools browser extension.
The extension basically injects/run some code in the current page, and displays the results.
I found that I can access the devtools panel code using this url: devtools://devtools/bundled/js_app.html?ws=127.0.0.1:9222/devtools/page/2786924A6A07EBBC4FE18A07D9D37BD4
But, with this url, the extension doesn't have any attached context (devtools.inspectedWindow) and doesn't know where to inject the testing code.
Is there another way I can use to access both the page and the devtools panel at the same time?
Thanks

Failed to execute 'replaceState' on 'History': A history state object with URL

We have faced this type of problem.We are Developing phonegap app.We don't changed any code.But unfortunately my eclipse stop.And then we changed project location.then we open html page in browser.We got error like this
Please guide to us.
You can test your app inside a web server, that solved my problem, or you can simply delete "history.replaceState()" in your jquery.mobile.js file, if you don't use the browser history in your mobile app
Waiting for chrome developers to fix this issue from the last update.

Fluentautomation with multiselect

I am having trouble selecting multiple values from a SELECT box via FluentAutomation.
Sample test case:
I.Open("http://www.htmlcodetutorial.com/forms/_SELECT_MULTIPLE.html");
I.Select(1).From("select[name='toppings']");
I.Select(2).From("select[name='toppings']");
I.Select(3).From("select[name='toppings']");
When this code is executed only the 3rd option is selected, whereas I would like all 3 options to be selected (This would be equivalent to a user holding down ctrl and clicking the 3 options).
This has been tested with Internet Explorer (v11.0.9600.17728) and Chrome (v42.0.2311.90)
Any insights would be appreciated.
Thanks.
I believed what you want is this:
I.Select(1,2,3).From("select[name='toppings']");
See the documentation here:
https://github.com/stirno/FluentAutomation/blob/b084f3e2638edf0a169f4286628706f042dc9339/Docs/v2/actions.select.md
Edit
It appears that there is a bug in the older version of Chrome WebDriver. Because FluentAutomation bundles the Chrome WebDriver in FluentAutomation.SeleniumWebDriver.dll, you must compile this on your computer (instead of using nuget):
Download the latest Chrome WebDriver: https://sites.google.com/a/chromium.org/chromedriver/
Download FluentAutomation source: https://github.com/stirno/FluentAutomation
Go to "{source path}\FluentAutomation.SeleniumWebDriver\3rdPartyLib\" and replace chromedriver.exe with the one downloaded in 1
Recompile FluentAutomation and use the compiled FluentAutomation.SeleniumWebDriver.dll instead of the one you got from nuget.
Good luck!
Edit 2
There is a way to override FluentAutomation's ChromeDriver. See #stirno comments below.

Can't see dynamically loaded code in Chrome Developer Tools 22

When I dynamically load a snippet of html containing javascript via AJAX, I cannot see that content in the source tab in the developer tools window in Chrome 22.0.1229.94. Tellingly, I went here
https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints#js_dynamic
This page shows an example developer tools window which is out of date. There is a button on the page to load a dynamic script and it does not show up in the source tab when you do.
As a work-around, I have found that adding
debugger;
to the script and reloading it will cause it to pause in the dynamically loaded code, but unfortunately, all the line numbers are greyed out and you can't set any breakpoints within the debugger.
Am I missing something here or what?
Thanks,
Rob
When you use a library or javascript code that you have loaded it dynamically, you can use the phrase
//# sourceURL=foo.js
at the beginning of your javascript code that foo.js is the name that will be assigned it. debugger will show it with that name.
This is true in chrome, and I think in firebug too.
In this case you can place a breakpoint in the dynamically loaded javascript code.
Possible duplicate of:
Is possible to debug dynamic loading JavaScript by some debugger like WebKit, FireBug or IE8 Developer Tool?
Don't know if this works or not in chrome (This definitely doesn't work for me now, may be in the past).
//# sourceURL=foo.js
Working Solution
For your dynamically loaded script via ajax to appear in your chrome source tool, you need to add the following line at the start or end (I prefer) location of your script file:
//# sourceURL=foo.js
And your script with name foo.js will appear at the left pane of source tab under (no domain) dropdown
->localhost
-- source/src
->(no domain)
-- foo.js
Alternatively you can add the below line in your script anywhere between the scripts.
debugger;
In chrome, you can use " debugger; " statement to break at a statement when debugger panel is open. Chrome will simply ignore this if the debugger panel is closed.
This will help stop your script in debugging mode and you will see your script in source (debugging) panel with name like VM****.
Hope this helps.
You can use //# sourceURL. Chrome doesn't seem to be supporting //# sourceURL for inline scripts. However, it does work on eval expressions. This article gives more details about naming eval blocks and naming of any anonymous functions in your code.
Instead of using eval, you can try embedding a script tag or JSONP may be.
Varunkumar Nagarajan
for me it happened on nodejs project.
i restarted server and open in new tab my app and tada!..
Alternatively, to fix this problem you can open developer tool in a seprate window by clicking the icon. Now reload your script, and it will shown in script tab as expected. I know this is not a solution but a work arround.

chrome cache removal for single files

recently I had to remove my entire cache to be able to view a webpage I was working on. This is fine I guess but it could be improved by removing specific pages from the cache.
the chrome.browsingData.remove, seemingly has no option for indicating individual pages for removal. I was wondering if this could be done externally, but I am not familiar with the chromium code. I was also wondering if there are any planned changes to the chrome.browsingData.remove implementation.
Many thanks
To remove a single file cache enter its URL into browser and do hard refresh.
If you are working on a webpage and wish to avoid caching (btw, it's recommended! :) You can do it today in Chrome DevTools.
Go to Settings (the icon in the bottom-right corner) and click on it.
Then, you will have an option 'disable cache' - mark it and you done.
Just don't forget to return this state when you done working as chrome will be faster with its caching schema.
Edit 10/Feb/2022: Access the remote dev tools documentation for a whole suit of tools available to override cached files while developing:
https://developer.chrome.com/docs/devtools/storage/cache/
If you are attempting to clear HTTP cached data, which was the original question in the post, then the network log is where it is possible. the guide for that is here:
https://developer.chrome.com/docs/devtools/network/#load
First find the file then release its cacged content by right clicking:
https://developer.chrome.com/docs/devtools/network/reference/#clear-cache
To remove all files (not single files) while in Chrome DevTools you should click on the Dev Tools settings then choose
"Disable cache (while DevTools is open)". This was the first option on the page - it is now (as of Chrome 103 in 2022) under network in Preferences.
Note that these settings are not the main Chrome settings, but are specific to Dev Tools.
You can reach DevTools by pressing F12 while on a web page you want to debug or by pressing Ctrl-Shift-I.
Edited 28 July 2022
If you're building the page dynamically, then during development, you can put a random string at the end of the URL used to load the script.
<script src="path/to/script.js?_=<%=Math.random()%>"></script>
This will cause a cache miss for that file but will use the cache for everything else (subject to cache-control headers and so on). Just remember to remove the parameter before pushing to prod!
UPDATE : 2019, April 20
Lately, I'm working with Chrome browser's inbuilt feature - Overrides. With this feature, we can write code for HTML, CSS, JS, etc directly in the console and see it on the web-page.
Here's a tutorial that might be helpful
Previous Answer :
I'm working with Google Chrome extension Resource Override.
After installing this extension, I'm overriding the resource which I want from the server instead of cache:
STEP #2 : Override the resource which you want fresh from the server:
⭐Important Note - Access the plugin from the developer-console instead of the browser
⭐⭐ I started with this approach but have moved to approach suggested by Lukas Greblikas in the answer above.
Good Luck...