Selenium VBA test case as a Function
The browser is automatically disposed once the variable of the driver is out of scope. For further information, I invite you to have a look at the official documentation: https://support.microsoft.com/en-gb/kb/141693
Here is an example with a local instance of the driver:
Private Assert As New AssertSub Main() Dim drv As New Selenium.FirefoxDriver drv.Get "http://stackoverflow.com" Call ClickLogo(drv) drv.QuitEnd SubSub ClickLogo(drv As WebDriver) drv.FindElementByCss("#hlogo").ClickEnd Sub
And another example with a global instance of the driver:
Private Assert As New AssertPrivate drv As New Selenium.FirefoxDriverSub ProcMain() drv.Get "http://stackoverflow.com" Call ClickLogo drv.QuitEnd SubSub ClickLogo() drv.FindElementByCss("#hlogo").ClickEnd Sub
To get the latest version in date working with the above examples:https://github.com/florentbr/SeleniumBasic/releases/latest