I created an extension that sendMessage's a variable into the content script. Which then returns data back to the popup JS code. Thing is, it stopped working.
I've been trying to debug this problem via inspect popup but it opens a window and immediately just closes. I've added a debugger; everywhere even at the beginning of the popup js and nothing happens. Nada.
Does anyone know how to really properly debug a popup js code?
Related
Is there a way to debug nightwatch even within the command chains, or debug the injected code in chrome DevTools?
For instance, I want to debug the "window" object:
I use chrome Version 59.0.3071.115.
According to ChromeDriver - WebDriver for Chrome the DevTools is always disconnected from ChromeDriver as soon as the DevTools opens. Meaning, if I inject the code within the execute command (images) the DevTools will close and I have to reopen it again? Meaning, I cannot even debug it in the front end?
Thanks!
Apparently, the only way to debug or set breakpoints within the command queue is by means of callbacks, as shown in the following example.
Setting a breakpoint to inspect a page in browser
Sometimes it is important to inspect a page in browser in the middle
of a test case run. For example, to verify used selectors. To pause
execution at the right moment set a breakpoint inside a callback:
browser.perform(function () {
console.log('dummy statement'); // install a breakpoint here });
The example where taken from https://github.com/nightwatchjs/nightwatch/wiki/Understanding-the-Command-Queue.
Except:
Except for the execute command, because nightwatch injects the specified script directly into the browser, which will be executed right there. Moreover, chrome only allows one DevTools per page, hence it will try to reopen the DevTools each time a command must be executed.
DevTools window keeps closing
This is normal.
When you open the DevTools window, ChromeDriver is automatically
disconnected. When ChromeDriver receives a command, if disconnected,
it will attempt to close the DevTools window and reconnect.
Chrome's DevTools only allows one debugger per page. As of 2.x,
ChromeDriver is now a DevTools debugging client. Previous versions of
ChromeDriver used a different automation API that is no longer
supported in Chrome 29.
If you need to inspect something in DevTools, the best you can do now
is pause your test so that ChromeDriver won't close DevTools. When you
are done inspecting things in Chrome, you can unpause your test and
ChromeDriver will close the window and continue.
Source: https://sites.google.com/a/chromium.org/chromedriver/help/devtools-window-keeps-closing
I have developed customize browser using IE WebBrowser Control in c++. Everything works fine. The only problem I am facing is when I am closing the browser. It closes normally if there is no to-and-fro of data happening like in light-weight website. But it hangs/freezes while closing if there is to-and-fro of data happening like audio player is running on the website or in a real-time update website where it keeps sending and receiving the data.
I am doing the clean closing and destroying of the browser as mentioned here. I also tried to navigate to about:blank before closing. Still nothing.
From the call stack I could see that it is still trying to run some JavaScript code while closing/destroying the browser. I tried to look into it if any-how I could clear or stop all activities but still I found nothing.
Any suggestions?
Try this:
IWebBrowser2::ExecWB(OLECMDID_STOP, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL)
I'm writing a devtools Chrome extension with a dev panel. The devtools script can use chrome.devtools.inspectedWindow.reload to reload the page and run a script before other scripts run (in every frame in the inspected window). However, the injected script is no longer run for subsequent page reloads and newly created frames.
How can I inject a script into the inspected window that is run at the start of every subsequent page load in the inspected window?
I know I can use a content script that runs at document_start, but that would run the script at the start of each page load regardless of whether the dev panel is open - and the script is intensive, so I'd like to avoid running the script when it's not needed.
Could the devtools script somehow listen for the beginning of page loads in the inspected window and respond by running a script in the page's context?
One option that you can use to avoid running the script when it's not needed, as you have said, is programmatic injection. As discussed:
Inserting code into a page programmatically is useful when your JavaScript or CSS code shouldn't be injected into every single page that matches the pattern — for example, if you want a script to run only when the user clicks a browser action's icon.
To insert code into a page, you must have the following:
your extension must have cross-origin permissions for the page.
It also must be able to use the chrome.tabs module.
You can get both kinds of permission using the manifest file's permissions field.
Once you have permissions set up, you can inject JavaScript into a page by calling tabs.executeScript.
As also discussed in chrome.devtools.inspectedWindow in executing code in the inspected window, use the tabs.executeScript method unless you need the specific functionality that the eval method provides.
However in Communicating Between Extension Components, please note that:
The DevTools page can't call tabs.executeScript directly. To inject a content script from the DevTools page, you must retrieve the ID of the inspected window's tab using the inspectedWindow.tabId property and send a message to the background page. From the background page, call tabs.executeScript to inject the script.
You may go through the given documentations for more information and examples.
How can i get the browser type in CODED_UI. I am new to coded ui automation. can you please help me out. Using BrowserWindow can we get the browser type.
By default your Browser type on Coded UI will be Internet explorer. Coded UI Uses Selenium to test Non-IE browsers and you have to set the browser type you want before you launch the browser.
So the question of getting your current browser type will be irrelevant, since you are the one setting it. It will be something like this,
BrowserWindow.CurrentBrowser = "Chrome";
Chrome = BrowserWindow.Launch(new Uri("http://yourwebsite.com"));
but, for some reason you do not know what your current browser is you can give a shot at,
browser.ClassName;
Note: It does not tell u explicitly, you have to extract it.
I have express.js with ejs templating.
I can see that for first request, debugger stops at break point.
But after ejs serves page on browser, any further requests never stops at break point.
I tried lot of things in frustation -> webstorm, eclipse, node-inspector,etc
Is there some config for ejs or experss that I am missing?
Even console.log is not printing anything. I know flow works for sure.
Actually it was my bad.
I was trying to debug js in public folder which is client side js.
So i have debug using chrome developer tools instead of server side debugging.