0

I have a flaky wifi access point that I'd like to automate to reboot every night.

It has a typical web interface for administration, and I want to use cscript / wscript to automate IE 11 to reboot the access point.

I'm aware that IE is discontinued, and webdriver / selenium are better. But I'd just like to stick to the built-in windows tools (ergo, internet explorer).

The problem: for some reason, my script can locate and fill in the password field successfully, but there's no response when I click() on the login button. The (JS) script looks like so:

var ie = WScript.CreateObject("InternetExplorer.Application", "ieEvent_");
ie.visible = true;
ie.navigate("http://192.168.0.xxx/");

function ieEvent_DocumentComplete(pDisp, URL) {
    WScript.echo(URL);
    if (URL.substring(0, 10) !== "http://192")  return;
    var txt_pass = ie.document.getElementById("admin_Password");
    var btn_login = ie.document.getElementById("logIn_btn");
    if ((txt_pass !== null) && (btn_login !== null)) {  // #1: login page
        WScript.echo("#1 login page");
        txt_pass.value = "password";
        btn_login.click();  // doesn't work?
    } else {
        ...
    }
}    

Yet, the exact same code works in the IE dev console:

btn_login = document.getElementById("logIn_btn");
btn_login.click();

Is there any reason click() might be blocked when executed via COM, but not in the dev console?

For the record, the device is a D-Link M15. For those familiar with the device, I know it has a built-in scheduled reboot function. Unfortunately, that functionality is disabled when the device is set to "Extender Mode".

1
  • Never mind, it turned out to be a timing issue (ajax requests hadn't completed yet so the button wasn't operable). Commented Jan 19 at 12:39

0

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.