What I'm trying to do?
I am trying to write an application based on such schema:
The chrome extension launches an application (.jar file) on my computer
The application launches another application (external, not written by me), I am passing data to it, it displays the window for user, user enters some data to it, and then this app returns the data to the parent app
The parent app processes the child app response and sends it back to the chrome extension
What's wrong?
When the window of the child app is displayed, the chrome extension is disconnected (it happens exactly at the same time). What follows, the result is not going back to the chrome extension.
What works:
If I omit point no. 2 (just mocking the answer from the child app), the result is returned to the chrome extension.
Including all points: the child app returns it's result correctly. The parent app catches it and tries to return it to the chrome extension (not succeeding, the extension is disconnected)
Also tried
I tried to do it using java multithreading (ExecutorCompletionService, Callable, Future), I wanted to launch the child app in a separate thread and block the main thread until the child is finished, it didn't help.
Solved!
The communication between the chrome extension and my app is through the standard input/output. Somewhere in the code of my app (written in java) there was System.out.println called. It made some mess on STDOUT and made the app disconnect from the extension. It happened in the same time with launching the external app as I saw it, probably didn't happen exactly at the same time, but some time before/after, something the person cannot see.
Multithreading has nothing to do with this problem.
Solution
I found and removed all code writing to standard output
Related
I am building a chrome extension that is supposed to aid in the debugging of software that runs on top of a website. This software can have a debug mode enabled that will cause a lot of output to the console using console.log.
I want to use my chrome extension to parse the console messages and show the important events in the UI for quicker debugging. However, I am not seeing a way to simply do this with the API. Is there something I am missing? Should I override the console.log function? How would I go about doing that?
There are two methods.
Override console.log, console.warn, and so on, in page context (this is important!). There are lots of examples (here's a random one). In your case it'll be even simpler as you'll just call the original method and transfer the arguments via CustomEvent to your content script (example), which will accumulate them.
Use chrome.debugger API with Console.messageAdded or Runtime.consoleAPICalled events. This will show a message bar in the entire browser about debugger being active unless you hide it globally by running chrome with --silent-debugger-extension-api command line, but that's somewhat dangerous if you accidentally install a malicious extension that uses chrome.debugger API.
I am trying to execute a Junit Jar in Jmeter. In the Script, chrome browser is launched and login screen of my website is displayed, where Username and Password is entered and login button is clicked. So when 2 user load is applied, 2 chrome browsers are launched which is as per the script. However, the credentials which is suppose to get enter in the 2nd Browser are overwriting the credentials field of the 1st Browser. So script for 2nd Browser is failing as nothing is getting entered in the login screen.
The scripts run successfully on Eclipse.
Headless browser. I have added the headless browser code in the script. Now the browser aren't getting launched, everything is running in the background, this should have solved the issue. But the issue still persists when putting the load of 2 users.
Most probably the issue is with your code, i.e. according to WebDriver FAQ
WebDriver is not thread-safe. Having said that, if you can serialise access to the underlying driver instance, you can share a reference in more than one thread. This is not advisable. You /can/ on the other hand instantiate one WebDriver instance for each thread.
So I would recommend either double-checking your Java code which is being used and ensure that there are no static functions or fields and WebDriver instances are put into ThreadLocal
An easier solution would be going for WebDriver Sampler which is compatible with JMeter thread model therefore there should be no race conditions.
You can install the WebDriver Sampler using the JMeter Plugins Manager
I am using GoogleApis to upload documents to Google Drive using the InsertMediaUpload class from the FilesResource namespace and the Upload method. It is working well for me with the following exception:
After calling InsertMediaUpload, a browser window appears asking the user to log into their Google (usually Gmail) account. If the user simply closes the browser window instead of clicking on "Accept" or "Cancel" then the current process appears to be hung. I suppose there should a timeout of a minute or two so that if the user opts to not log in the current windows application will not simply hang and stop working indefinitely.
There is no need for sample code here. What should happen when the user simply closes the browser window instead of clicking cancel if they are no longer interested in uploading a document? Crashing (or hanging) the current process should not be a possibility, but that is what occurs. One would hope closing the browser window would have the same effect as clicking the cancel button -- just another way of opting out of an upload to Google Drive, right?
Thanks in advance for any help with this.
You're not supposed to get authentication message from InsertMediaUpload class. You should handle authentication by yourself. Authentication browser window you get is for your development convenience, not for production code. Please take a look at .net quickstart. In this quickstart, you'll see GetAuthorization method which handles authentication. Modify this method on your needs and you'll get what you want.
What would be the easiest way for me to set up a Chrome extension that starts when I log in to my Windows account, and can be connected to a WebSocket server to check for, say, new messages, and then pop open a desktop notification, that clicks to the messages web page?
I expect that making an extension is straight forward, as well as getting it to communicate with WebSockets, and making the desktop notification.
But what about making it automatically start when I log in to the computer? What would be a good way to do this in Windows? I am not interested in having the chrome browser to open up at log in, but I certainly don't mind if I see Chrome in the task bar.
You might look into chrome.runtime.onStartUp: https://developer.chrome.com/apps/runtime#event-onStartup, which is
"Fired when a profile that has this extension installed first starts up."
Also, you can use chrome.alarms to schedule a function to run every minute or so, to open a WebSocket somewhere, etc.
The app may try to unload itself if there are no active windows, so you can call some action in chrome.runtime.onSuspend (like loading an XHR somewhere) to cause onSuspendCanceled to trigger.
Silverlight is made so that you can run it in a browser. That is cool. So, if I want to pass variables from the command line so that it can be used to populate fields in the silverlight app, how is that done?
You know, like you can with javascript (I think) or php (I am pretty sure).
Silverlight has Init parameters which is a key/value map that you can fill in your Html page and get the values in Application_Startup event. However this does not apply to Silverlight apps running in OOTB (out of the browser) mode.
This MSDN page shows a trick if you run your app both in and out of browser, so that you can save the InitParams values when running in the browser and save it back to Isolated Storage for when you run the application in OOTB mode.