Jump to content

Try this:

public class LinkOpener {     private String path;        public LinkOpener(String pPath)    {        path = pPath;    }        public void open(String pLink)    {        Runtime rt = Runtime.getRuntime ();         try {            rt.exec(path+" "+pLink);        } catch (IOException e) {            e.printStackTrace();        }    }    }

now you only have to find a way to extract the browser path. heres an example of how it works for chrome:

 

        LinkOpener m = new LinkOpener("C:\\Users\\*yourUsername*\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");        m.open("http://linustechtips.com/main/");

hope this works for you ;)

Link to comment
https://linustechtips.com/topic/30281-java-interact-with-webpage/#findComment-388672
Share on other sites

Link to post
Share on other sites

Instead of the above I would recommend working with the Selenium package. If you take a bit of time to learn it, it will be very useful in the future if you are doing complex webpage tasks. I'm in a job right now where I am creating selenium tests for a large website. It is easy to use and is a webtesting standard. Here is the link: http://docs.seleniumhq.org

Link to comment
https://linustechtips.com/topic/30281-java-interact-with-webpage/#findComment-391806
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×