-
Dec 4th, 2024, 05:43 PM
#41
Junior Member
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!
-
Dec 5th, 2024, 05:23 AM
#42
Thread Starter
Member
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")
-
Dec 5th, 2024, 07:41 AM
#43
Junior Member
Re: SeleniumVBA
Just change driver.StartChrome to driver.StartEdge in "test_ImplicitMaxWait".
-
Dec 5th, 2024, 10:10 AM
#44
Thread Starter
Member
Re: SeleniumVBA
OK, makes sense. Thanks.
Now I get a permission denied in Wait and SendKeys on the NavigateTo line
-
Dec 5th, 2024, 10:47 AM
#45
Junior Member
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!
-
Dec 5th, 2024, 11:02 AM
#46
Thread Starter
Member
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
-
Dec 5th, 2024, 11:25 AM
#47
Junior Member
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!
-
Dec 5th, 2024, 11:36 AM
#48
Thread Starter
Member
Re: SeleniumVBA
I don't see vbscript. But FWIW, I know that my system does run vbs files (and isn't that vbscript?)
-
Dec 5th, 2024, 11:44 AM
#49
Junior Member
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
-
Dec 5th, 2024, 11:51 AM
#50
Thread Starter
Member
Re: SeleniumVBA
Nope, permission denied on: Set oRegExp = CreateObject("vbscript.regexp")
-
Dec 5th, 2024, 12:02 PM
#51
Junior Member
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).
-
Dec 5th, 2024, 12:31 PM
#52
Thread Starter
Member
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
-
Dec 5th, 2024, 12:35 PM
#53
Junior Member
Re: SeleniumVBA
Yooooohooooo! Please let me know what you find out from MWB. Cheers!
-
Dec 5th, 2024, 04:17 PM
#54
Thread Starter
Member
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.
-
Dec 5th, 2024, 04:41 PM
#55
Junior Member
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!
-
Dec 5th, 2024, 08:47 PM
#56
Junior Member
Re: SeleniumVBA
TML59 - did you get my reply to your PM? Not sure the app sent it to you.
-
Dec 6th, 2024, 04:32 AM
#57
Thread Starter
Member
-
Dec 6th, 2024, 01:48 PM
#58
Thread Starter
Member
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?
-
Dec 6th, 2024, 06:12 PM
#59
Junior Member
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.
-
Dec 7th, 2024, 06:33 AM
#60
Thread Starter
Member
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
-
Dec 7th, 2024, 07:25 AM
#61
Junior Member
Re: SeleniumVBA
Looks pretty good though I would move the .DeleteFiles command up before the command that downloads.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|