Is it possible in Java to launch a browser and navigate to a specific URL then execute some Javascript on that page?
Currently I've got this:
public class Launcher {
public static void main(String[] args){
try{
Desktop.getDesktop().browse(new URI("www.facebook.com"));
}
catch(IOException e) {
System.out.println(e.getMessage());
} catch (URISyntaxException e) {
System.out.println(e.getMessage());
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
}
This, for example brings me to the facebook website.
In Javascript I could do now like this:
document.getElementById("email").setRangeText("loginName");
To fill in my username.
My question is, is this possible to do from inside Java once you opened the webpage through the desktop.browse()
?
EDIT2: can I navigate using this Desktop.browse()
? What if I want to go to a different url?