JAVA - how to open a browser tab from eclipse? - javascript

I've just got back into Eclipse after 2 years. I have finally forgiven it after I last used it for a mobile development class in 2015 (that was put together as well as a duct-taped carnival ride).
I have taken several for-credit coding classes before, and over the summer, I'm going to take several programming classes via Udemy.
The problem is, I've never built a worthwhile desktop app before via actual coding (because I don't think Multimedia Fusion 2 counts). Even worse, I rarely ever use Java.
So now, with blind and eager ambition, I'm looking to develop a desktop app for myself (and for others if it's of any use) that will allow users to create entries where they can enter urls and titles (merely for aesthetic purposes, no effect on the browser), and when some condition is met, the desktop application will open Chrome tabs with tabs to those exact urls.
From this, I'm hoping to understand Java better, like I understand C++. It would be really nice if I could just do it for any browser on the first try, but if I had to do each browser separately, I would like to try Chrome firstly, as it's what I use.
If all goes well, I could attempt to make the same app for Chrome as a Chrome App, but for now... :)
Here's the core idea/plan:
Declare a vector of a class called "tabs", where this class contains 2 strings: one for the title, the other for the url. Both should be editable by the user, but for simplicity's sake, we'll just make them an "enter these fields once and now don't edit them" kind of thing to start with.
When the user wants to add a url to open in Chrome, we add to (or "push back", whatever it's called) the tabs vector with whatever data the user enters.
When a user presses some key or button, then Chrome will open with those tabs.
Here are my ideas on how I could approach this:
I might be able to download some kind of official Chrome development tools into Eclipse that would allow me to manipulate the browser functions, such as opening and closing tabs. If I can pass arguments into those functions, I could iterate through my tabs vector and open them until the end. I've looked for tools like these, and though I may have come across the right one(s) already, nothing really struck me as the "I am your solution!" package deal. I almost imported an official package into Eclipse that looked super-promising, but the official link was dead. :(
I might be able to use Javascript somehow, because if I understand correctly, I could create a Window object, iterate through the tabs vector, and just call the window.open() function and pass in the url at [i] to the function. But then, would this work for a desktop app?? I've read that NW.js can use Javascript/CSS/hmtl for desktop apps, so I think it could do this, but I've also heard it's a little buggy on Windows 10.
I'm also looking into Electron, while still on the idea of desktop JavaScript. It looks pretty reliable, actually.
But beyond all those ideas, I don't absolutely know what tools I need to use or which ones I could even feasibly use to do this. :/ The options are a little overwhelming, and I'm not sure which ones are worth looking into to do what I want, given the idea I've shared (I'll worry about the rest of the program when the time comes). This really doesn't seem like a hard project, and I really want to get my feet wet into app development, but sometimes I feel a little lost on where to go.
I don't really know what exactly to ask, besides: "Even if it means downloading something else entirely, what IDE/dev kit/whatever could get me started in the right direction and do this task?
Hope this isn't too vague a question, cheers,
-Jon

There are 2 simple ways to do this..
The first: In the file menu, navigate as follows... Window -> Show View -> other -> General -> Internal Web Browser
The second: Right click your project in Project Explorer -> Run As -> Run on Server (assuming you have your server properly set up, etc...)

Related

web app- Would it be possible to disable Windows+Printscreen?

I am trying to prevent users from taking screenshot in my web application written in Java.From my research,it seems highly unlikely.I did found a link below:
https://stackoverflow.com/questions/3130983/stop-user-from-using-print-scrn-printscreen-key-of-the-keyboard-for-any-we
It's able to disable the printscreen button but it doesn't disable if a user tries to use windows+printscreen.Now, I know even if I do managed to disable it, there's other third party application like snipping tools,camera,etc to take a screenshot but that's way beyond my control and I'm not looking into those.
I was just wondering is there a way to disable Win+Printscreen to prevent user from screenshotting?
If anyone has done it before, I appreciate any sort of suggestion.
Simple answer: No
Have a quick think about why you need to hide this info, does it really matter if other people see it? I assume that you have proof that you came up with your conclusion/process first? The information will never remain exclusive forever, especially not on the internet.
You normally do not have access to higher level controls so it is normally not possible with a web app. Having said that, there are several possible ideas:
Send your content directly to the graphics device/card via an API so that it is never visible to the operating system screen space (Where print screen works). However, with the right tools it is still possible to catch a graphics stream but it's a little harder for the average user.
Make your webapp launch a custom desktop application with more control over the OS (Download an exe and run it?)
Design a plugin/extension for a web browser that limits the use of printScreen, and then only show content on your webapp if your site can see that the plugin/extension is installed and running. This may not work with the way that Chrome and Firefox now manage plugins, it would need more investigation.
The best answer would be to only show limited info/conclusions on your webapp, and keep all the proof of concept hidden. Then you can make people sign-up to your app if they want more information, and then give a strict set of criteria that must be met.

Communicating two or more browser tabs, which could be the best method?

I want to design a small (at least, the very basics for now) IDE to make websites and applications with HTML, CSS, Javascript and a full LAMP stack.
One of the things I would like to do is to be able to open the preview window in a different browser tab (instead of having it in an HTML-encoded tab (a <div> element or similar), like Dreamweaver does) or even, while in source mode, being able to display the toolset in another browser tab and displace this tab onto a second display (or even a third one, although I have just one display, but it's for illustrating my situation).
Once deployed in another browser tab, I want for every browser tab to reflect any changes done to any of the other browser tabs.
For example, if I have the source view in one display and open the properties grid in another and I change a color input value, I want the output view to reflect this change in color for whichever component gets the update.
I have my mind quite clear on how to approach the data structures, how to do the preview, data caching, storing the project data, etc.
What I don't have that clear is how to effectively communicate the tabs between them. One idea is to use a combination of AJAX requests and server-sent events (SSEs) to communicate but, even if that could work, looks like crude to me.
I was thinking on something like websockets with message passing. I could encode any changes in a given component, send them to the server and have it route to the appropiate listeners for each one of them to reflect any change locally.
I have very litte experience with websockets, though... so I'm in doubt. Can you give me a hint on what could be the most efficient method here?
I've experimented recently with WebSockets, in combination Java on Server and JavaScript on client side. First wanted to go with simple Java SE, had a nightmare, didn't succeed to make it work and at end the found this tutorial:
https://blog.idrsolutions.com/2013/12/websockets-an-introduction/
Works like charm. Just stick with environment mentioned there - Java EE, GlassFish, NetBeans... Not saying that NetBeans is best IDE or something...
Of course, there is NodeJS option for back-end if you preffer JavaScript.
But generally speaking WebSockets works...and works well. :)

How to update source codes of a phonegap application from server

I have been developing phonegap applications that need to make updates oftenly. The problem is pushing a new ipa to iTune Store take too long. So, I uploaded the application source codes(minified javascript) to my server and download it from application and "eval" the minified js files. But i feel using eval has limitations and also not the right way. So, can someone tell me the right way to accomplish this.
thank you so much.
I'd love to have something like this as well. You're already ahead of me w/your eval() approach - but I'd have the same concerns as you there. Here's what I'm aware is out there on this topic - hope this helps?
IdeaPress(?)
I just recently caught wind of this one - not sure how feasible but it claims to do exactly what we'd like. I have to say the main site looks a bit flaky but I will definitly be checking this out to see if it's feasible or not.
HockeyApp?
HockeyApp (possibly dead-end now). I thought there used to be a pretty clear solution for PhoneGap devs to integrate the HockeyApp API/feature set with their mobile apps but a recent Google search on this is turning up much less than I would think - so maybe it's a dead end now? http://goo.gl/GQOv5o
org.apache.cordova.file
This requires more work and I haven't pushed far enough yet to see if it truly could be a means of updating the app post-app-store-deployment. But based on what I've read if you're just updating code for your WebView you shouldn't have to worry about App Store rejection or anything. Related tutorial
Testflight App Testing (Apple)
I haven't gotten to play w/this yet but sounds like it could be promising for at least the beta/testing phase of development. I, like you, need a solution for end-users, not app testers, but I'll still be looking into this soon as it might replace me having to maintain my own over-the-air app installs for the best/testing periods.

Methods to (unit) test the interface of a website

I'm wondering what are the best practices to test the "interface functionality" of a website.
I'm interested in what methods are available for testing the interface and dynamic generated contents. In particolar I struggle to figure out whether it is possible to create automated tests for actions that require user interaction, or if it is just a waste of time and I should just get some beta tester do this type of work.
I'll try to give some examples:
on SO when you type the title of your new question some "related questions" appear. Obviously you can implement some sort of test that tells you that you got the correct number of related questions, and that they get displayed, but how do you test the "correctness" of the links? Would you setup a mock set of questions (always the same) and check that the returned questions are some pre-established ones? That would work, sure, but it's hardly testing the robustness of your search algorithm. What happens when other questions are added to the pool? Are the returned results still "related"?
Clicking on a certain button a JS is called that generates a "popup div", that the user can move around. Again, how do you automatically test this kind of interface? You can test for the appearance, but how do you test for the movement?
You have an interface to upload files to the site to embed in your message (like the image icon here on SO). So the user is required to 1) press the button 2) browse for the file 3) wait for the upload 4) press OK and finally he/she will see the image in the message. Again, I can see how you can automate the test for the upload (e.g. try upload a "normal" file, then one which is too big, of an unsupported format and so on). But what about the use of the interface? If the OK or the Browse buttons don't work for whatever reason it's no use that the upload works as, at the end of the day, you still cannot upload your file and see it in your message.
Obviously all of the above are fairly straightforward to beta-test (just tell a bunch of users to test your website and they'll notice if anything goes wrong), but can you do (and more importantly would you spend time implementing) automated tests on this kind of things? Also, when beta testing, would you have testers "run wild" and do whatever they want on the site, or rather tell which functions you'd like them to test. I'd propend for the 1st but I'm open to suggestions.
What we use at our place is Selenium. It has a few quirks, but overall it has allowed us to increase test coverage enormously, with I think a few thousand new system tests clicking around. Note that one can argue if this is really "unit" testing. That depends on your stack, I guess. We have to have our system running for this, so it's more integration testing.
For pure unit testing of JS we use QUnit, and HTMLUnit has proven somewhat popular as well, for "middle of the road" tests that don't use a real browser but still gives you a DOM and whatnot.
Some of you problems may be answered by visual testing, and there is a great framework for it: http://sikuli.csail.mit.edu/
It allows you to expect visual results and programmatically control a web page.

Automated browsing with javascript?

I'm trying to do some browser automation, but I'm having some problems. Basically, what I'd like to do is load a set pages, set some forms options, click a button and view the results for each page that I open. Originally, I tried to do this by placing the pages I wanted to automate in iframes and then using javascript to drive the interactions I want in each, but that results in a Permissions Error, since the sites I want to automate are not on my server. Is there any way around this? The other possibility I've thought of is to use QT's webkit class and the evaluateJavaScript method to accomplish what I'd like to do, but this seems a bit more heavy weight for something that is, conceptually, pretty simple.
The tasks that I wanted to accomplish weren't really test related, so a lot of the test-frameworks don't fit the use case that I had in mind (I did try to use Selenium, but ran into problems). I ended up doing what I mentioned in original question and injecting javascript into pages through QT. This ended up working pretty well, although it was a pain to debug, since the javascript had to be passed in as a string and the base environment provided by QT's webkit class doesn't reveal a whole lot.
Check out Selenium: http://seleniumhq.org/. It lets you automate Firefox and is probably the easiest to get start with.
Are you trying to do test automation? If so, there are plenty frameworks for that, like Selenium, WatiN, WebAii and even that built in Visual Studio.
Some of them (WebAii is my favorite) allow you to launch test in a real browser like FireFox.
If a peace of software you searching for is more like form filler, than take a look at iMacros, thay have a complete browser-side scriptable solution.
An easier way of doing this would be to use a web debugging proxy and injecting javascript that way. This should allow you to debug the code you wrote within the browser.
I haven't personally used web debugging proxies, But I wrote my own proxy and did this a while ago just for fun and it worked great.

Categories