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.
Related
I am struck up in my below task, hope this idea will be very useful for many.
In my company they use several Health Monitoring tool and we do the Health Checks manually.
We have a separate health check plan and process, where we go to Web Applications like Site Scope or open certain jars like Spectrum CA (runs as a JNLP file) and check for the server status/health data manually.
As we have more than 50 monitoring tools like that I suggested to automate the Health Checkups.
Initially I was suggested to do the automation using Python but I am a JAVA Web developer so I moved to Selenium/Jsoup and use Web-scraper concept to fetch the information and do the health checkups. I am able to do considerable progress using Selenium to automating the manual Health Checks using the Web Application.
Problem: As I mentioned we also need to do certain health checkups using jar, desktop apps or jnpl file (applet), I am not sure on how to proceed in automating these. We are not supposed to use any paid tools or unreliable freeware which record and replay the manual desktop operations.
I do not have any idea on those, so can you please suggest me a tool or testing automation tool for these Desktop applications where I should be able to LogIn into it, Enter some text in the TextBox, Search, filter, navigate and get a value and finally verify whether the health is green ?
Note: Few of the application are legacy application so they don't use any api calls.
There are 2 free tools which can cater to your needs which can be used alongside Selenium w/ java:
1) AutoIT - good for window based applications
2) Sikuli - an image based automation Tool
I do not have any idea on those, so can you please suggest me a tool or testing automation tool for these Desktop applications where I should be able to LogIn into it, Enter some text in the TextBox, Search, filter, navigate and get a value and finally verify whether the health is green ?
For the above question, Winium can be used for desktop app automation. It is similar to Selenium. You can write code in java to automate the process. below is the git link for Winium.
https://github.com/2gis/Winium.Desktop
I was looking at FlaUI, you can have a look at this as well. This works with c# though
https://github.com/Roemer/FlaUI
I am looking for a way to interact with websites via Java. It should be a desktop application which connects to the website and performs a defined action. How would I go about writing a program like that? Are there tools I can use? I'm at the very beginning of this project.
Try looking into a headless web-browsers, there are a number of them that allow you to programmatically interact with a webpage.
For a headless webkit that supports javascript you can try PhantomJS (http://phantomjs.org/) although there are many others out there.
need to code a bot that needs to do the following:
Go to a jsp page and search for something by:
writing something on a search box
clicking the search button(submit button)
clicking one of the the resulting buttons/links(same jsp page
with different output)
get the entire html of the new page(same jsp page with different
output)
The 4th one can be done with screen scraping and I do not think I need help with it. But I need some guidance to do the options from 1 to 3. Any links or just some keyword that will help me Google to learn about it will be appreciated. I plan to do this with java.
My suggestion is to use Selenium (http://docs.seleniumhq.org/download/).
Install Selenium IDE in your firefox, and it can record what you do on a website, store it into a script and reply it.
This video (http://www.youtube.com/watch?v=gsHyDIyA3dg) is gonna be helpful if you are a beginner.
And if you want to do it in Java, its easy, just export the scripts in Selenium IDE to JUnit Webdriver code.
Of course you can use Selenium Java webdriver in Java to write your program to operate on website directly.
Selenium automates browsers. That's it. What you do with that power is entirely up to you.
The above steps can be done by using selenium(which is a testing tool in java)
Even points 1 to 3 are screenscraping - you're figuring out (using either manual or automated means) what's there in the page and performing actions on them. You could try exploring the Apache HTTP Client for an easy way to run HTTP commands and get responses.
I hope you're doing this for legitimate means - screenscraping is almost always frowned upon if done without permission.
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.
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