Program that enters form data in a web browser - java

I am trying to build a program that once a browser is opened and a login window (Let's say for Facebook) is presented, it will enter in my username and password for the site. I am familiar with the Robot class, and this could be used for the technique, however this is a messy solution. Could anyone suggest a way to go about this? Any good classes? Or is it better just to construct an add-on for a browser?

A plugin gives you direct access to a browser's API so it would be the best approach. That's how Roboform does it, you may want to take at look at what they did.

Related

Disabling the java.awt.robot inside of a browser

Would it be possible to disable a Java program that contains a Robot from running inside of a browser? I don't think so, but I figured I'd ask anyway.
For example, a robot that clicks the the "Ask Question" button on the SO site can be created in Java (based on the pixel location of the "Ask Question" button) using the Robot class. Can somebody alter the stack-overflow website such that said Java program can't run on it?
No, they could alter the site and move the button or add a captcha challenge or something like that, but essentially, to the SO servers a request from your java program looks like any other request.
Web site admins really only have the request URL and the request headers for filtering or blocking traffic. You can't manage requests from java.awt.robot directly; you'll have to look for something else to work with.

Selenium web driver with applet

We have use of applet in web application, this applet is provided by thirdparty to validate user in there database. However, there is a user login and once system validate user, system display text box in applet to enter key code for given text. This key code keep changing and user needs to provide exact key code as sent to there mobile or email. Is there any way to read key code on applet using selenium webdriver and also to send value in field?
This applet is complete code by third party and we do not have any access to their code, we have applet popup when user click on button and user need to enter credential and key code to proceed further..... We are using automation script selenium webdriver with java
Any help would be really really appreciate.
Thanks,
Since you are not able to make any change in the applet, (In case your applet only plays role as a CAPCHA) I strongly recommend you to make a "backdoor" in your code to bypass the keycode. I think it's the only choice you have right now.
If you create a "backdoor", please take a good care at security matters.
Hope help

Web Browser in a Java Application

How can I open a webpage from a java application and enter username and password into it? I have seen questions here where people have referred to lobo or DJ Native Swing.
But as I am very new to java these libraries seem quite complex to me and I can not find a good tutorial in it, please refer to some good library with a solid tutorial which can be a beginning ground for me.
Note: I am developing a Java Swing application and show the user a page opening and user name and password being submitted.
What application do you develop? Web? Desktop/swing? Console? Mobile?
Take a look at Apache's HttpComponents project
It is not clear what you want to do.
1) Do you want to show it to the user?
join to WebKit browser in Java app on multiple platforms
2) You want to fetch some data from a web page that requires login?
then you should join to HttpClient login, search and get the XML content
Your question is not clear, are you trying to write a java application that will open a browser and enter data automatically?
If this is what you want then you can use selenium, a plugin for Mozilla. You can record your mouse movements, all your actions will get recorded as a jUnit test case.
You can then modify this junit test and read in the usernanme and password programatically from a file (or what ever you are trying to do.). This test can be run as a stand alone java application.

Can I get the URL of any other browser window?

I want to read the web address of all open windows. As soon as the window closes, I should know it too.
One way to do this is by asking the user to download a firefox plugin. This plugin should monitor the user web address.
But is this possible? How to go about executing it. I am pretty decent in Java and PHP.
EDIT:
What if the user wants to give permission to access all the websites he or she visits?
I want to display in a visual manner the statistics of the sites being visited by users who grant permission.
As noted, this cannot be done with standard JavaScript/DOM methods that run inside a page, for security and privacy reasons.
You could definitely do it with a Firefox add on, plugin or extension.
I suggest reading the Firefox addons developer guide and the Developer Hub in general. The language used to develop for Firefox is JavaScript.
nsIWindowMediator can be used to enumerate open windows, and properties can be obtained through the nsIDOMWindow objects. As explained here,
"While you can use JavaScript to get child windows opened from the parent window, you cannot get dialogs or windows that have no relation to that window. To overcome this limitation, nsIWindowMediator makes it possible to access all of Firefox's windows."
this likely violates the same origin policy, which rules this out
it basically controls the code so that it does not read anything it did not create
so no spying can be done
No, this would be a major security and privacy issue.
This is definitely a security violation similar to sniffing; and would require certain privileges to run on each platform (such as an activeX or plugin or a privileged applet).
However, this can be done using javascript only the page containing the script it self is responsible for opening windows (meaning not all windows such as window opened by user) - if that is what you are looking for, let me know.

Launching a website from within a program, and inputting data to specific fields

Although I've been programming for a few years I've only really dabbled in the web side of things, it's been more application based for computers up until now. I was wondering, in java for example, what library defined function or self defined function I would use to have a program launch a web browser to a certain site? Also as an extension to this how could I have it find a certain field in the website like a search box for instance (if it wasnt the current target of the cursor) and then populate it with a string and submit it to the server? (maybe this is a kind of find by ID scenario?!)
Also, is there a way to control whethere this is visible or not to the user. What I mean is, if I want to do something as a background task whilst the user carries on using the program, I will want the program to be submitting data to a webpage without the whole visual side of things that would interrupt the user?
This may be basic but like I say, I've never tried my hand at it so perhaps if someone could just provide some rough code outlines I'd really appreciate it.
Many thanks
I think Selenium might be what you are looking for.
Selenium allows you to start a Web browser, launch it to a certain website and interact with it. Also, there is a Java API (and a lot of other languages, by the way) allowing you to control the launched browser from a Java application.
There are some tweaking to do, but you can also launch Selenium in background, using a headless Web browser.
as i understand it you want to submit data to a server via the excisting webinterface?
in that case you need to find out how the URL for the request is build and then make a http-call using the corresponding URL
i advice reading this if it involves a POST submit

Categories