I need some kind of webbrowser backend (don't know if it's proper name for such thing). Generally I need high abstraction of html page with controls, ability to create events (button push or selecting an item from combobox), javascript interpreter, etc.
Are there anything of that kind?
I think you want something like HtmlUnit. From the page:
HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc. just like you do in your "normal" browser.
It has fairly good JavaScript support (which is constantly improving) and is able to work even with quite complex AJAX libraries, simulating either Firefox or Internet Explorer depending on the configuration you want to use.
You might also want to check out Selenium which lets you control a real browser programmatically.
Related
I want to be able to use Java to tell it to go to X url when X browser is open/running (my lingo is terrible). (Firefox/Chrome/IE is already up, and I want it to go from the default page to let's say Twitter.)
Most of the solutions are using java.awt.Desktop to launch native browser with a url in it, but that isn't useful if I want to change the url later on. (Already on Twitter-Home Page, but want to go to Twitter-Contact Us afterwards.)
The other solutions I've seen involve using Selenium WebDriver, but I also need to eventually learn how to basically force the Java to read a long list of URLs off an excel and simply verify that url isn't dead, and then do this on the Native Android browser, for example. So the Selenium might not be the right choice. Granted, you can also tell me this is an awesome choice for this too if it truly is. I haven't really been exploring Selenium.
Sorry for asking such a basic question. Company wants QA Automation without training/hiring an Automation QA. My end goal (aside not getting canned), is to see if I can get a bunch of urls to load on specific browsers. I can sort of (praying) be able to do stuff with it afterwards.
A simple trick would be to create an add-on( if you know javascript ) which will be quite similar in chrome and firefox (for IE I have no idea in my days it needed BHO) and send websocket commands from java to your addon. But this needs a java websocket server running where your addon will connect when the browser opens. Rest of communication can be carried upon the protocol lines of your requirements.
There are multiple parts to your question.
Read urls from excel.
Use Apache POI to do the same. Selenium code can use the same.
Check that the urls are not dead.
Use any java http client, (apache) to do that without even opening a browser. If the link is dead, it will be dead for all the browser.
Open the links in a multiple browsers.
Selenium is perfect for this. I am assuming that after the page is loaded you have way of validating that the page is correct. Selenium is very powerful here.
Target native android browser too.
I do not know of much difference between this and the previous question unless you are also testing site display based on browser size. The browser is more or less the same as chrome with webkit rendering engine.
This is for an offline application. However, I would like the front end to be run in a web browser. What I want is, a simple gui design in HTML/CSS. I want to be able to execute java commands at a button's press. Furthermore, I would like to be able to display and read information from the browser. Is this feasible?
You could use JxBrowser. The knowledge base contains some pretty good example. Unfortunately, it is not free though.
I was wondering how I could embed a browser like view in a Java client application, at the same time that I can interact with it by means of JavaScript.
The problem that triggered this question is the following:
The interface of my application consists of a (Google) map and some svg stuff.
This is easy to do in a browser.
However, I also need access to some special Java libraries that can process some information from the map (e.g., certain coordinates in the map) and that answers values that should influence the browser view (e.g., a path should be drawn over the map).
My first idea was to implement the Java side behaviour as a REST web service, so from JavaScript I will invoke this webservice sending relevant information about the map and using the answer to update the map. Nevertheless, for my current needs (this is only a prototype) using webservices is a bit too much of infrastructure.
Is there a way I could just:
embed a browser like view in my Java application.
Interact from the Java side with this view by means of JavaScript functions implemented in the web page displayed in the browser view (such as these functions will influence the rendering of the page in the browser like view) ?.
I found other questions related to how to embed a browser in a swing application (e.g., Embedding web browser window in Java) and JDIC seems to be able to do this. Although some people report it is difficult to make it work in OSX (the OS I use) and do not mention if it is possible to interact with the browser by means of JavaScript.
It seems to me that in Android it is possible to make JavaScript calls from the Java (Android) side, so probably this is also possible in plain Java.
Thanks for any pointer !
With Java FX 2 you can. You get a webkit webview there. Can interact with it back and forth with java<->javascript.
For an example embedding google maps see: http://java-buddy.blogspot.se/2012/03/embed-google-maps-in-javafx-webview.html
You can embed java fx in swing with JFXPanel if you don't want to go with 100% JavaFX yet.
If you can use swt, take a look at SWT Browser widget
For javascript you can use
http://www.mozilla.org/rhino/
I need to implement a simple browser in java. I've been researching several possibilities including JxBrowser, JBrowser, JavaFX (WebEngine + WebView), among others. JxBrowser has potential but it's a paid library, which I would like to avoid.
This browser needs to be able to process all web functionalities including JavaScript and HTML5 while capable of connecting through proxies. Therefore the best solution may be to use a web engine like Gecko.
So I'd like some advice on libraries which are capable of implementing Gecko engine (including XULRunner) with the possibility of changing core Gecko preferences.
Also, if you know any other possible solution that doens't include Gecko, feel free to discuss.
Have you tried SWT Browser widget?
For proxy in SWT Browser, see How do I set a proxy for the Browser to use?,
is JavaFX capable of loading and embedding OCX Controls? I would like to use the Internet explorer in my Application, because the WebKit browser lacks support for ActiveX. And since I have to rely on third party ActiveX Controls (I know they are evil), I am bound to the IE.
This question is not purely related to "Can I use OCX in Java" because I would like to have some kind of component for JavaFX I would like to use.
Or do I have to rely on libraries posted here:
Use a .OCX Control in Java
Thanks in advance,
Sven
You have to rely on the libraries posted in the link you supplied in your question.
Or you need to write your own JNI interface.
If you do access OCX components, you may need to place them in their own window rather than sharing a window created by a JavaFX stage as you may run into issues with the JavaFX renderer conflicting writes on the window portions in which the OCX components are displayed - you would have to try it and see what happens to confirm.
The easier way to do this may be to request that users of your application set their default browser to IE, and then call the JavaFX hostservices.showDocument(uri) api to launch an IE page which embeds the OCX components you need.
Another alternative is to:
Embed your JavaFX application as an applet in a web page.
Also embed your activex controls in the web page.
On display of the web page, check the browser and, if it isn't IE, tell they user that the must be using Internet Explorer.
Have the user accept any miscellaneous security warnings the Browser displays.
Have the user (or perhaps JavaScript) resize the browser window to fullscreen (see IE9 Full Screen Mode or Full Screen Browsers with JavaScript).
Communicate between your active X controls and java app using javascript invoked via calls from the javafx/javascript bridge and control your active X controls via VBScript embedded in the page.
It would probably work, but it is such an ugly Frankenstein solution . . .
If you can convert your media to a format which JavaFX supports and just play it back direct through JavaFX, that would be much preferable, or it may also turn out that due to a deep ActiveX integration requirement that JavaFX is not the best solution to your problem and you could be better off with something like Silverlight.