GCuser99 / SeleniumVBA

A comprehensive Selenium wrapper for browser automation developed for MS Office VBA running in Windows
MIT License
83 stars 17 forks source link

OneDrive/SharePoint bug fix + Option Explicit + others... #14

Closed GCuser99 closed 2 years ago

GCuser99 commented 2 years ago

Discussed in https://github.com/GCuser99/SeleniumVBA/discussions/13

Originally posted by **6DiegoDiego9** July 18, 2022 Hi GCuser99! Congratulations for your SeleniumVBA project, it looks very useful and promising! I chose to use it as my primary Selenium library in my projects so I'll try to give my contribute to improve it. I was going to submit a PR for the first set of modifications but since I renamed many files (adding a "Web" prefix for aggregation) and that was detected as new files by GitHub Desktop instead than changed files, I opted to write to you here instead. I made the following changes: 1) fixed crash when the workbook is on a disk synched with OneDrive or SharePoint.
See detailed info in my comments in the new ThisWorkbook_DiskPath function 2) moved the GetAbsolutePath (and the new ThisWorkbook_DiskPath) functions to a module, avoiding duplicated code in multiple classes 3) added "Option Explicit" and consequent required declarations to every module and class. This is useful for avoiding to leave unseen typos that may lead to unpredictable results. For example it allowed me to spot your typo "CheckComptibilityLevel = -1" at debug time, otherwise it would just silently create a new variable CheckComptibilityLevel assigning -1 to it instead than to the correct CheckComp**a**tibilityLevel variable (!) 4) renamed the class names adding the Web prefix where not already there. The reason for this is to aggregate the classes related to this Selenium library in both the Project Explorer and IntelliSense, useful when the files are integrated (added) to an existent (other) project with other classes.
I find that the first advantage of this library is to avoid dependencies, to be able to send or share a single xlsm/xlsb file to third persons, so for me the typical scenario is to integrate it to workbooks with other pre-existing modules and classes. Here is the resulting [seleniumvba_v1.4.2.zip](https://github.com/GCuser99/SeleniumVBA/files/9130603/seleniumvba_v1.4.2.zip)
GCuser99 commented 2 years ago

@6DiegoDiego9,

Great set of improvements - thanks! I will go ahead and commit your changes pretty much untouched, except for the following line in GetInstalledDriverVersion function of WebDriverManager class changing:

Dim vparts() As Variant

to:

Dim vparts As Variant

I was on the verge of adding Firefox browser support and reworking the WebDriverManager class, so if have any more suggestions please get them to me soon so that we can minimize mis-synchronization. I will commit your changes along with my planned changes within the next week or so...

Good work!

GCUser99