adamdriscoll/selenium-powershell

Unable to load types when wrapping module

dc31xx opened this issue · 2 comments

I'm sorry for my noobish powershell question, but I'm unable to wrap your module inside my own utility module (for personal use). I used the using module statement over Import-Module and did reference your module als one of the ExternalModuleDependencies. I keep getting errors with the types you dynamically added inside SeleniumClasses.ps1

Cannot validate argument on parameter 'Browser'. Unable to find type [SeBrowsers].
Cannot find the type for custom attribute 'ValidateURIAttribute'. Make sure that the assembly that contains this type is loaded.

Did you perhaps try to reference your own module in another module? Any docs or help on how to solve this would be much appreciated.

@dc31xx I am not very familiar with ExternalModuleDependencies.
From what I understand, this is mostly when you want to add a dependency that is not available from PowershellGallery.
I might be wrong on that and feel free to enlighten me but if you do not have specific reasons to use that, use RequiredModules instead.

I created a dummy module with Selenium as a RequiredModule and was able to use the module properly.

My Psm1

using module Selenium
function test-stuff {
    Start-SeDriver -Browser Chrome -Position 1920x0
    Stop-SeDriver
}

My psd1
Everything basic +
FunctionsToExport = @('test-stuff')
RequiredModules = @('Selenium')

Tested with both PS 5.1 and Ps 7.2 on Windows 10

Thanks al lot @itfranck . It was my lack of pwsh knowledge that led me to ExternalModuleDependencies.