SeleniumBasic icon indicating copy to clipboard operation
SeleniumBasic copied to clipboard

How can i Install Selenium without running the SETUP ?

Open RonanVico opened this issue 6 years ago • 9 comments

Hello ,my boss( Who runs a VBA Enterprise) asked me to do some automatic systems , i put the idea on the table about of seleniumBasic he agree(bcoz he saw some examples mine) and i have done like 80% of the project and almost 1 month or more, but there is a problem now.

He said to me , i cant run any Setups on the client , so i need some help, SO the question is ::

HOW CAN I IMPORT THE SELENIUM LIBRARY WITHOUT RUNNING A SETUP ? Can i have all the code in a Module and just import that ?

Sorry for my bad english , i really need a answer thanks very much !

RonanVico avatar Mar 17 '18 02:03 RonanVico

i have the same problem i try to register the DLLs manually but it's not working .. so any help ?

3Tarekmohamed avatar Mar 17 '18 06:03 3Tarekmohamed

Hello there, please look at the following important points.

  • Selenium Type Library is not a General Library, which is being default arrived with VBA compiler.
  • So You have to install it on the client machine before you run the Application.

It's okay to have at least few things manually to setup before you run your application on your client's machine. Just explain your boss, by adding every time manually the library, you have the advantage of securing your application from the unauthorized access and use by anonymous.

And if you still need to automate the whole test then I want to suggest you the learn AutoIT. It might help you to achieve your task.

Thank you. @

vbamagician avatar Mar 22 '18 20:03 vbamagician

Thx vbamagician , i will learn about tha AutoIt. But what u dont understand is that i cant run an .EXE on a big client , thats impossible , so may i just stop using that library and start using the IE Object , Thx anyway

RonanVico avatar Mar 23 '18 09:03 RonanVico

Like Ronan asked is there an alternative method to install the SeleniumBasic library in Excel References? We are not allowed (we do not have the rights, .exe files are blocked) to run .exe files on our system. In advance many thanks for your response.

Dutchgent avatar Jul 19 '21 04:07 Dutchgent

Here's a script to install without privileges: https://gist.github.com/florentbr/6be960752fc852ee99eece6b4acb8ba7

To install, extract the original setup with innoextract, add a recent "chromedriver.exe" and run the script from there. It installs to "%APPDATA%\SeleniumBasic" but you'll still have to be able to run "chromedriver.exe". If the group policy is banning the location, you'll have to edit "set _LOCATION=..." to change it to an allowed one. If you can't find one, just install it in the same folder as Chrome.

florentbr avatar Jul 19 '21 09:07 florentbr

Hi florentbr, thank you for creating the install.cmd file which I believe shall be greatly helpful to people like us who are not permitted to run the a setup file in client's computer.

For those who had the below error like me:

Screenshot 2021-07-23 132548

Simply copy the install.cmd file to the extracted "app" folder. and run it from there.

longvh211 avatar Jul 23 '21 05:07 longvh211

@longvh211, yes the required files are in app\:

  • extract the original setup with innoextract and copy the following files present in app to a new folder : Selenium.dll Selenium32.tlb Selenium64.tlb Selenium.pdb
  • add a recent "chromedriver.exe" to the created folder
  • add install.cmd to the created folder and run it

florentbr avatar Jul 23 '21 17:07 florentbr

Here's a script to install without privileges: https://gist.github.com/florentbr/6be960752fc852ee99eece6b4acb8ba7

Many thanks, much appreciated

Dutchgent avatar Jul 24 '21 05:07 Dutchgent

@florentbr Thank you very, very much for the "silent install" it not only saved my day it also probably saved the project.

BTW: Attached a AutoHotkey script can be found for updating the chromedriver.exe with AutoHotkey. It works great and was one step to automate everything.

The source, which I modified slightly is from https://www.autohotkey.com/boards/viewtopic.php?t=68186 and written from AHK_User.

    ;Function Updates the Chromedriver by checking the versions and downloading the latest chromedriver.
    ;Written by AHK_User
    ;Thanks to tmplinshi
    ;Modified by Dophin2

    SChrome_UpdateDriver() {

    ;Path of SeleniumBasic and Chrome Browser
    EnvGet, Dir_Local_Appdata, LOCALAPPDATA
    Dir_Chromedriver:= Dir_Local_Appdata "\SeleniumBasic\chromedriver.exe"
    Dir_Chromedriver:= "C:\Users\" A_UserName "\AppData\Local\SeleniumBasic\chromedriver.exe"
    Dir_ChromeBrowser:= A_ProgramFiles "\Google\Chrome\Application\chrome.exe"
    ;Other possible path for Chrome Browser
    Dir_ChromeBrowser2:= Dir_Local_Appdata "\Google\Chrome\Application\chrome.exe"

    ;Split Path of Selenium
    SplitPath, Dir_Chromedriver, , Folder_Chromedriver

    ;If SeleniumBasic not installed then return
    IfNotExist, %Folder_Chromedriver%
    {
        ;msgbox Selenium not installed on %Folder_Chromedriver% 
        return
    }

    ;If Browser not installed then return
    IfNotExist, %Dir_ChromeBrowser%
    {
        IfNotExist, %Dir_ChromeBrowser2%
        {
            ;msgbox Chrome Browser not found        
            return
        }
        else
            Dir_ChromeBrowser = %Dir_ChromeBrowser2%
    }

    ;Get Version of Chrome Browser	
    FileGetVersion, Version_Chrome, %Dir_ChromeBrowser%
    Version_Chrome := RegexReplace(Version_Chrome, "\.\d+$")
    ;msgbox Version of Chrome Browser is %Version_Chrome%

    ;Check if chromedriver is installed
    IfNotExist, %Dir_Chromedriver%
    {
        ;msgbox chromedriver could not be found here %Dir_Chromedriver%        
        Version_ChromeDriver =
    }
    else
    {
        ; Get Chromedriver version
        Version_ChromeDriver := RunHide("""" Dir_Chromedriver """ --version")
        ;~ DebugWindow("`nVersion Chromedriver:" Version_Chromedriver,Clear:=0,LineBreak:=1)
        Version_ChromeDriver := RegexReplace(Version_ChromeDriver, "[^\d]*([\.\d]*).*", "$1")
    }
    ;msgbox Version of ChromeDriver %Version_ChromeDriver%


    ;~ DebugWindow("Version Chrome:"  Version_Chrome "`nVersion Chromedriver:"
    Version_Chromedriver,Clear:=0,LineBreak:=1)

    ; Check if versions are equal, if not download it
    if InStr(Version_Chromedriver, Version_Chrome){
            ;MsgBox,68,Testing,Current Chromedriver is same as Chromeversion.`nDo you still want to download?
            ;IfMsgBox, No 
            ;{
            ;	return
            ;}
            ;Already correct version installed
            ;msgbox No update necessary.
	return
    }

    ; Find the matching Chromedriver to the Chrome Browser
    oHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    oHTTP.Open("GET", "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_"  Version_Chrome, true)
    oHTTP.Send()
    oHTTP.WaitForResponse()
    Version_Chromedriver := oHTTP.ResponseText
    ;~ DebugWindow("The latest release of Chromedriver is:" Version_ChromeDriver,Clear:=0,LineBreak:=1)

    if InStr(Version_Chromedriver, "NoSuchKey"){
            ;es gibt keinen passenden driver
	;MsgBox,16,Testing,Error`nVersion_Chromedriver
	return
    }
    ;msgbox The latest matching release of Chromedriver is: %Version_ChromeDriver%


    ; Download the matching Chromedriver in the directory of this file
    Url_ChromeDriver := "https://chromedriver.storage.googleapis.com/" Version_Chromedriver "/chromedriver_win32.zip"
    URLDownloadToFile, %Url_ChromeDriver%,  %A_ScriptDir%/chromedriver_win32.zip
    ;msgbox Driver downloaded

    ; Unzip Chromedriver_win32.zip in the SeleniumBasic folder
    fso := ComObjCreate("Scripting.FileSystemObject")
    AppObj := ComObjCreate("Shell.Application")
    FolderObj := AppObj.Namespace(A_ScriptDir "\chromedriver_win32.zip")

    ;Close Chromedriver if running
    while ProcessExist("chromedriver.exe")
    {
        Process,Close,chromedriver.exe
    }

    FileObj := FolderObj.ParseName("chromedriver.exe")
    AppObj.Namespace(Folder_Chromedriver "\").CopyHere(FileObj, 4|16)
    ;msgbox Unziped to Folder for Selenium %Folder_Chromedriver%	

    FileDelete, %A_ScriptDir%/chromedriver_win32.zip

    ;msgbox Chromedriver was installed in the selenium folder
    return
    }


    RunHide(Command)
    {
    dhw := A_DetectHiddenWindows
    DetectHiddenWindows, On
    Run, %ComSpec%,, Hide, cPid
    WinWait, ahk_pid %cPid%
    DetectHiddenWindows, %dhw%
    DllCall("AttachConsole", "uint", cPid)

    Shell := ComObjCreate("WScript.Shell")
    Exec := Shell.Exec(Command)
    Result := Exec.StdOut.ReadAll()

    DllCall("FreeConsole")
    Process, Close, %cPid%
    Return Result
    }

Dolphin2001 avatar Apr 22 '22 11:04 Dolphin2001