0

At work we have 7 tools that I have to launch every morning. All the tools are on web pages.

So I have to open 7 links and click several buttons to launch the tools.

I would like to automate this operation. I used a C# code (similar to this one) which works fine

SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
ie.Visible = true;
ie.Navigate("https://www.google.co.in");
//Wait for page to load
while (ie.Busy) 
{
    Threading.Thread.Sleep(100);
}
dynamic allLinks =     ((mshtml.IHTMLDocument3)ie.Document).getElementsByTagName("a");
foreach (mshtml.IHTMLAnchorElement link in allLinks) {
    //Do some validation to find out the required link
    if (link.href.Contains("https://accounts.google.com/ServiceLogin")) {
        link.click();
    }
}

But actually we are not allowed anymore to use C# for licence reasons...

Is there any way to do that in HTML/Javascript ? (Open a link and click a button on it)

I'm not asking someone to do the work for me, but if you just have a nice tutorial or tip to look at it will be great.

Thank you.

3 Answers 3

1

You can use Javascript and use

window.open("www.url.com","_self")

to open the links.

You can find more info on window.open @ http://www.w3schools.com/jsref/met_win_open.asp

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. This works fine. I still need to click some buttons on each page. Is that possible please ?
Hi @ThomasCarlton, I do not see it a good idea to invoke the click event. But nothing is impossible. So you can use apply() method (developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…) for this: var elem = document.getElementById("linkid"); if (typeof elem.onclick == "function") { elem.onclick.apply(elem); } My suggestion is to wrap up your logic into a method and invoke it from javascript.
1

You could use a selenium framework, have a look at this one for example https://code.google.com/p/selenium/wiki/WebDriverJs

http://webdriver.io/ this is for Node.js

and here's a tutorial http://code.tutsplus.com/tutorials/an-introduction-to-webdriver-using-the-javascript-bindings--cms-21855

Comments

0

You could just set-up your browser to open all 7 as home pages when it starts up.

5 Comments

That's an interesting tip. However I still need to click some buttons on each page.
Why? Aren't these seven sites on the web? With unique URIs?
Yes they are. But for every page, I have to select manually some criterion and click "Load" to load the data I'm interested in.
I think you're probably looking at a Javascript/JQuery solution - can you be more specific about the things you have to do to get the pages loaded?
I first type the page adress (which is the first operation easily automated), and then I fill a text box, then hit one button (This is where I'm struggling).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.