简体   繁体   中英

How to open HTML link and click button?

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.

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

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

您可以将浏览器设置在启动时将其全部7作为主页打开

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM