Jump to content
Sign in to follow this  
Docfxit

Navigate Firefox

Recommended Posts

I'd like to start by starting a new tab in Firefox and signing into my Sonicwall.

I'm experiencing an error with this script where it should put the user name in once.

It's putting the user name in twice.

It should enter:

UserName

Password

The script is putting in:

UserNameUserName

Blank

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
TrayTip("clears any tray tip", "", 0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
; Log Into Sonicwall
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
Local $command="C:\Programs\Firefox\firefox.exe -new-tab "
$url = "https://192.168.1.1/auth.html"
Run($command & $url, "", @SW_MAXIMIZE)

WinWait("SonicWall - Authentication - Mozilla Firefox", "")
If Not WinActive("SonicWall - Authentication - Mozilla Firefox", "") Then WinActivate("SonicWall - Authentication - Mozilla Firefox", "")
WinWaitActive("SonicWall - Authentication - Mozilla Firefox", "")
sleep(500)
Send("UserName{TAB}")
sleep(500)
Send("'Password'{ENTER}")

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

;Danp2  Thanks for the suggestion.

When I went to FAQ 31, I got lost.  I tried finding MozRepl addon and it is no longer.

I think it suggests I use _FFClick.  I did a Google search and found you suggested to use Firebug.  When I tried to find Firebug it is no longer.  It suggests to use the new Firefox Developer Edition.  So I installed it.  This is what it started with:

SonicWallLogIn.thumb.jpg.6788925d6a2d3676d2011498daf4f360.jpg

I don't know enough about HTML code but I think what I need is:

var swlStore = function () {
    var pageId;
    var username = _getCurrentUsername();
    var singleton = null;
    var globalPageId = '__global_pageid__';

    var metas = document.getElementsByTagName('meta');
    for (var i=0; i < metas.length; i++) {
        if (metas[i].name === "id") {
            pageId = metas[i].content;
            break;
        }
    }
    if (pageId === undefined) {
        pageId = globalPageId;
    }
    else if (pageId === globalPageId) {
        console.warn('The page is having a very internal page id, which could cause problems in some ways.');
    }


    function storageAvailable(type) {
        try {
            var storage = window[type],
                x = '__storage_test__';
            storage.setItem(x, x);
            storage.removeItem(x);
            return true;
        }
        catch(e) {
            return false;
        }
    }

    function _getCurrentUsername() {
        if (top.gCurrentUserName) { return top.gCurrentUserName; };
        try {
            var storedUsername = _getRaw('curUsr');
            storedUsername = JSON.parse(storedUsername);
            return storedUsername.data;
        }
        catch (e) { }
        return null;
    }

    function _resetCurrentUsername(usrName) {
        if (typeof(top.gCurrentUserName) != 'undefined' && top.gCurrentUserName !== usrName) {
            top.gCurrentUserName = null;
        };
        try {
            var storedUsername = _getRaw('curUsr');
            storedUsername = JSON.parse(storedUsername);
            if (storedUsername.data === usrName) {
                return;
            }
        }
        catch (e) { }
        _set(localStorage, 'curUsr', usrName);
    }

    function _normalizeOpts(opts) {
        if (typeof(opts) === 'boolean') {
            throw new Error('option typed as boolean is obsoleted.');
        }
        return $.extend({
            isGlobal: false,
            isForAllUser: false
        }, opts);
    }

    function _normalizeKey(key, opts) {
        var ruleRe = /[a-zA-Z0-9!@#$%^&*()\-+=_\[\]{};,.<>/?|\\]+/;
        var nKey = '';
        if (!ruleRe.test(key)) {
            throw new Error('The key for swlStore should match the rule '+ruleRe.toString());
        }
        if (opts.isForAllUser) {
            nKey += key;
        }
        else {
            nKey += username + '::';
            nKey += (opts.isGlobal ? globalPageId : pageId) + '::' + key;
        }
        return nKey;
    }

    function _set(storage, key, val, opts) {
        val = JSON.stringify({data: val});
        if (val === undefined) { return; }
        storage.setItem(key, val);
    }
    function _getRaw(key, opts) {
        var val = sessionStorage.getItem(key);
        if (val === null) { val = localStorage.getItem(key); }
        return val;
    }

    singleton = {
        set: function(key, val, opts) {
            opts = _normalizeOpts(opts);
            key = _normalizeKey(key, opts);
            _set(localStorage, key, val, opts);
        },
        sessionSet: function(key, val, opts) {
            opts = _normalizeOpts(opts);
            key = _normalizeKey(key, opts);
            _set(sessionStorage, key, val, opts);
        },
        get: function(key, opts) {
            opts = _normalizeOpts(opts);
            key = _normalizeKey(key, opts);
            var val = _getRaw(key, opts);
            try { val = JSON.parse(val); return val.data; }
            catch(e) { return undefined; }
        },
        remove: function(key, opts) {
            opts = _normalizeOpts(opts);
            key = _normalizeKey(key, opts);
            sessionStorage.removeItem(key);
            localStorage.removeItem(key);
        },
        exists: function(key, opts) {
            opts = _normalizeOpts(opts);
            key = _normalizeKey(key, opts);
            var val = _getRaw(key, opts);
            if (val === null) { return false; }
            try { val = JSON.parse(val); return val.hasOwnProperty('data'); }
            catch(e) { return false; }
        },
        resetUserName: function(usrName) {
            _resetCurrentUsername(usrName);
            username = _getCurrentUsername();
        },
        getCurrUserName: function() {
            return _getCurrentUsername();
        }
    };

    var fallback = {
        set: function(key, val, opts) {
            outputFallbackWarning();
        },
        sessionSet: function(key, val, opts) {
            outputFallbackWarning();
        },
        get: function(key, opts) {
            outputFallbackWarning();
            return undefined;
        },
        remove: function(key, opts) {
            outputFallbackWarning();
        },
        exists: function(key, opts) {
            outputFallbackWarning();
            return false;
        },
        resetUserName: function(usrName) {
             outputFallbackWarning();
        },
        getCurrUserName: function() {
             outputFallbackWarning();
             return undefined;
        }
    };

    function outputFallbackWarning() {
        if (console) {
            console.error('There is no localStorage or sessionStorage available on this platform, the UI may not be behaving properly.');
        }
    }

    return (storageAvailable('localStorage') && storageAvailable('sessionStorage') ? singleton : fallback);
}();

Can someone help me create the AutoIt code I need to enter the UserName and Password?

Edited by Docfxit

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...