I need to open a browser with URL and then wait till person clicks a special button. And if it happens, return true. Can I implement it with java tools or should I use javascript?
You should use JavaScript. Java is a Server side language, so all processing of Java code will be completed before the user has the chance to interact with the page. JavaScript (traditionally) works on the client-side and is commonly used to capture user interactions with the browser.
yes, Java Script or any frame work that builds on Java script like Jquery works for you. If understands you correctly,
create Hyper link
Browse the page that you needed
Place HTML button on the page, write onClick logic on that button to return true.
Related
I want to send a command to my browser, let's say chrome.
For example, I use a website which has a really neat audio player, i know this audioplayer has a javascript function called prevTrack() and nextTrack() etc etc etc.... what i wan't to do is to create a program (in java/c#) that would go into the browser console and send that command, if for example, I hit some kind of hotkey "ctrl + n" for example.
Is there any way to manipulate chrome like that?
Thanks
You could write an application which incorporates the browser into Java using something like http://djproject.sourceforge.net/main/index.html - it can open a browser window, navigate to a location, and then execute arbitrary Javascript.
Is it possible to call the JavaScript of a website without opening it in webview.
I am using URLConnection to get the html but I want to click a link on host website that in turn call a JavaScript function through Java code.
I want either to call JavaScript function or the link on click of a button on activity
webview.loadUrl("javascript:") is able to do it but only after opening in webview.
As I know it is impossible in current Android. In 4.5 there will be some script-engine to execute js or other scripts. BTw, why do you need this - to get content after click on content? seems strange..
I've got a need to navigate java-applet programmatically and I am not that keen on Java platform. So lets assume I've got IE process stated with appropriate java applet loaded. Next I need to have some actions taken to this particular applet, like, lets say, sending WM_COMMAND to dialog along with BN_CLICKED code like I do with Windows in C. Assuming it's not a regular window I can refer to using HWND, I would like to ask someone for recommendations on how to do this.
As I understand you want to navigate (sending keystrokes and mouse clicks) a java-applet on the client side. It depends if you own the applet (say: you have the code and can change it) or if the applet is closed source and you just want to remote it.
In the first case use javascript to automate it. Change the containing HTML page to include some Javascript and pass parameters to the applet as described in the Java Tutorials.
If the applet accepts parameters, but you cannot change the HTML page, use a GreaseMonkey alternative for IE.
Your other approach (sending Windows Messages from an extern application to IE) should also work. Start Spy++ (use the 64bit version if you are using a 64bit Windows), choose "Search - Find window..." and drag the "Finder Tool" icon over the applet and release it. You will see then the HWND and if you press search you will see the window inside IE window hierarchy. So, yes you can send keystrokes and mouse clicks to a browser.
If I would automate the browser I would use Geb. You code a "web site test" in Groovy, just look at the Geb index page.
You could try to record a navigation through the applet with FireFox + "Selenium IDE" then export it and try run it in a Java Application with the Selenium IE WebDriver.
Information about Selenium can be found here : http://docs.seleniumhq.org/
Maybe this question will also help you : How to automate Java applet?
If flash is not installed, i want to replace the flash animation with a jquery animation.
BUT if flash and js are not installed, i want to display a div with a message to the user.
how is it possible to check if flash is not running at the clientside without using js?
kind regards,
Use a javascript event to replace your message with the Flash animation. If Javascript is not running, you will see the message instead.
SWFObject is a great little tool for completing exactly what you want.
Add to HTML body classes: "no_flash no_js". They will be your default when js & flash not available.
Then when you have js, with it's help remove no_js class.
With help of js try to determine flash and if it's present, show flash else -- js animation.
Do it the other way around:
Display a div with a message
If JavaScript is on, replace the div with either:
a) a Flash animation, if Flash is installed or
b) a jQuery based animation
I'm working with the eclipse SWT toolkit, and I'm trying to use it to create a browser window that only passes mouse clicks to the underlying document conditionally (I want to stop Flash and Javascript in the page from getting clicks). I'd like some way of doing one of:
Examining mouse events as they come in, and only passing them on to other listeners based on conditions I specify.
Removing all listeners from a window, and only putting back the ones I want.
Are either of these possible?
Browser, like other SWT components, have addMouseListener method. So you could implement your own listener a pass only which one you want.
see javadoc of browser
Edit
According to your request, there could be two possible ways to do it.
First, you could use listening of events from JavaScript in browser (there is no way to avoid JavaScript if you work with html pages). If you know that you will have Mozilla browser render core (you have to install XUL Runner), you could use JavaXPCOM, but that's big unknown for me.
snippet - listen for DOM mousedown events with javascript
Second, you can call Java functions from JavaScript (again, handle onclick event, and then decide on Java, if you don't want to use JavaScript for it).
snippet - call Java from JavaScript
But frankly both ways are more ugly-er that proposed way by pure JavaScript.