Page 2 of 2 FirstFirst 12
Results 41 to 61 of 61

Thread: SeleniumVBA

  1. #41
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Thanks much for trying again. Those two attachments in your post are corrupted: " Invalid Attachment specified. If you followed a valid link, please notify the administrator". I'm curious to see your second attachment!

  2. #42

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    Weird... I've seen that in one of your earlier posts as well. Here's a re-try...

    If I make the changes to the INI file, I get this:
    Attachment 193642
    Then, if I manually place the file "msedgedriver.exe" in the Downloads folder and try again, I now get the same (as it tries to find chromedriver and not msedgedriver

    (I'm running "test_ImplicitMaxWait")

  3. #43
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Just change driver.StartChrome to driver.StartEdge in "test_ImplicitMaxWait".

  4. #44

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    OK, makes sense. Thanks.

    Now I get a permission denied in Wait and SendKeys on the NavigateTo line

  5. #45
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Excellent. Can you try one more thing and if it does not tell us something, then will not bother you anymore :-). Run following code in the SeleniumVBA.xlsm file. It checks whether VBScript's RegExp is working on your system.

    Code:
    Sub testVBScript_RegExp()
        Dim oRegExp As New VBScript_RegExp_55.RegExp
        Dim matches As VBScript_RegExp_55.MatchCollection
        
        oRegExp.Global = False
        oRegExp.Pattern = "\s(\d+\.\d+\.\d+\.\d+)"
    
        Set matches = oRegExp.execute("Microsoft Edge WebDriver 130.0.2849.80")
        
        Debug.Print matches(0).SubMatches(0) 'prints 130.0.2849.80
    End Sub
    Is your Windows 11 Pro computer using Windows 11 24H2? I'm asking because it's new, and there have been quite a few reports of issues - here is one:

    Windows 11 24H2 - VBSCRIPT Disabled.

    You can determine your windows version:
    System Information-> Help tab -> About System Info...

    Thanks much for your help and patience!

  6. #46

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    No problem to help you, I'm fine to do some more testing. And I do appreciate your patience!

    I'm using 23H2 (and not -yet- 24H2).

    Your script generates a "permission denied" on this line: oRegExp.Global = False

  7. #47
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Ok, I think that nails the problem. VBSCRIPT seems to be blocked/disabled on your system.

    You can try this to enable if you want:

    System -> Optional features -> View features

    In the "Add an optional feature" search box type "vb"

    Hopefully VBSCRIPT shows in the search results - click on it, Next, Add

    Otherwise if that does not work, I am at a loss as to what to tell you. MS has plans to phase-out VBSCRIPT by 2029, but they promised to keep it enabled until 2027, and then after that an optional feature until 2029.

    The only other things I can think of is a bad Windows install or AV blocking.

    If you can get VBSCRIPT to start working then I'm happy to help with SeleniumBasic to SeleniumVBA conversion if needed.

    Good luck!

  8. #48

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    I don't see vbscript. But FWIW, I know that my system does run vbs files (and isn't that vbscript?)

  9. #49
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Darn it - was afraid that would be the result. Hail Mary - does the code below work?

    Code:
    Sub testVBScript_CreateObject()
        Dim oRegExp As Object
        Dim matches As Object
        
        Set oRegExp = CreateObject("vbscript.regexp")
        
        oRegExp.Global = False
        oRegExp.Pattern = "\s(\d+\.\d+\.\d+\.\d+)"
    
        Set matches = oRegExp.execute("Microsoft Edge WebDriver 130.0.2849.80")
        
        Debug.Print matches(0).SubMatches(0) 'prints 130.0.2849.80
    End Sub

  10. #50

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    Nope, permission denied on: Set oRegExp = CreateObject("vbscript.regexp")

  11. #51
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    If you Google "vba CreateObject("vbscript.regexp") Permission Denied" you should see quite a few results - below is one:

    https://stackoverflow.com/questions/...ting-procedure

    Many of them blame MalewareBytes AV (in case you are using that).

  12. #52

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    That's it. I use MWB and when I disabled, this worked. :-)

    There were no pop-ups so I had no way of knowing. I opened a case with MWB (I'm a registered user) to find out how to allow this for Excel

  13. #53
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Yooooohooooo! Please let me know what you find out from MWB. Cheers!

  14. #54

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    I already received a response from Malwarebytes. I tested it and it works

    Here's what they told me to do.

    If you can verify that you are trying to use a macro, then you can do the following

    Open the Malwarebytes program
    click on Settings (cog wheel on the left)
    click the protection tab > under "Exploit Protection" click the "Advanced Settings" button
    click the "Application Hardening" tab
    scroll down to the setting called "Disable loading of VBScript libraries" > Scroll over to MS Office and uncheck that setting for MSOffice > click apply.

    The other layers of protection in Malwarebytes and other protection techniques in our Exploit protection should still keep you well covered.

  15. #55
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Awesome and thanks - I made note of this on the GitHub repo:

    https://github.com/GCuser99/SeleniumVBA/issues/133

    If you decide to move forward with SeleniumVBA, don't forget to test it with auto_detect_and_update=True in the SeleniumVBA.ini file and let me know if you need anything else or have further feedback!

    Cheers!

  16. #56
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    TML59 - did you get my reply to your PM? Not sure the app sent it to you.

  17. #57

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    I did, thanks!

  18. #58

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    OK, now that this is solved, I converted my code and it worked immediately.
    I changed the ini file to have the edgedriver download to the same folder as the SeleniumVBA DLL (seemed more logical to me).
    Then I changed the print settings to metric (maybe you can add a commented out metric config there?)
    I see that implicit_wait defaults to zero. Why is that? Wouldn't it be more logical to set this to e.g. 10000 always?

    And last question: my code downloads something from a webpage, how to I change the download folder for this one session to a specific folder that is used by my program?

  19. #59
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Great to see it is working for you now. Yeah it does make some sense to set implicit wait to a value greater than 0 always. We did give that some thought early on and decided to honor the WebDriver W3C standards which defaults to zero.

    On changing the download folder during a specific session... You need to use the WebCapabilities object to do that. There are some examples in the module test_FileUpDownload. Here is one:

    Code:
    Sub test_file_download2()
        Dim driver As WebDriver
        Dim caps As WebCapabilities
        
        Set driver = New WebDriver
       
        driver.StartEdge
        
        'set the directory path for saving download to
        Set caps = driver.CreateCapabilities
        caps.SetDownloadPrefs downloadFolderPath:=".\", promptForDownload:=False, disablePDFViewer:=True
    
        driver.OpenBrowser caps
        
        'delete legacy copy if it exists
        driver.DeleteFiles ".\test.pdf"
        
        driver.NavigateTo "https://github.com/GCuser99/SeleniumVBA/raw/main/dev/test_files/test.pdf"
        
        driver.WaitForDownload ".\test.pdf"
        
        driver.CloseBrowser
        driver.Shutdown
    End Sub
    Hope that helps.

    EDIT: good suggestion on the commented-out metric print settings - will add that on the next version update
    Last edited by GCUser99; Dec 6th, 2024 at 08:19 PM.

  20. #60

    Thread Starter
    Member
    Join Date
    Feb 2024
    Posts
    43

    Re: SeleniumVBA

    Great, I changed the implicit wait in the INI file. Since your answer I've been looking around as well ;-)

    Here's what I have now (and it seems to work!). Any final comments? I commented out the regular Wait as I thing with the 'waitfordownload' I don't need that.

    Code:
        Dim Driver As SeleniumVBA.WebDriver
        Set Driver = SeleniumVBA.New_WebDriver
        '
        With Driver
            .StartEdge
            .OpenBrowser invisible:=True
            .ImplicitMaxWait = 10000
            'Site
            .NavigateTo "https://<site>"
            'Login credentials
            .FindElementByID("USERNAME").SendKeys "<username>"
            .FindElementByID("PASSWORD").SendKeys "<pw>"
            'Click login button
            .FindElementByID("<something> ").Click
            'Click submenu to the download-page
            .FindElementByLinkText("<link text>").Click
            'Click download-button
            .FindElementByXPath("//*[@title='<element tekst>']").Click
            .DeleteFiles ".\<the name of the file to be downloaded>"
            .WaitForDownload ".\<the name of the file to be downloaded>"
            ‘.Wait 1000
            .CloseBrowser
            .Shutdown
        End With

  21. #61
    Junior Member
    Join Date
    Nov 2023
    Posts
    24

    Re: SeleniumVBA

    Looks pretty good though I would move the .DeleteFiles command up before the command that downloads.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width