quite some time has passed since my last post :).
He explains the code in the comments but unfortunately that it isn't enough for me to understand the topic.
Here is the code which I used and worked:
$env:PATH += ";C:\Temp\PSL\" # Adds the path for ChromeDriver.exe to the environmental variable
Add-Type -Path "C:\Temp\PSL\WebDriver.dll" # Adding Selenium's .NET assembly (dll) to access it's classes in this PowerShell session
$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver # Creates an instance of this class to control Selenium and stores it in an easy to handle variable
Here is my understanding and questions:
It seems we are loading some Net dlls. But after we added the DLL we are creating some object using "New-Object" based on the DDL. Please correct me if I'm wrong.
1) From where would I know how to use the dll or create a object from it if I can't read the .dll itself in Plaintext or any IDE? Sure I have the filenames but that's it "Webdriver.dll" + "WebdriverSupport.dll"
I'm talking about this part of the New-Object command "OpenQA.Selenium.Chrome.ChromeDriver".
2) is there any other way to load a dll besides Add-Type -Path "C:\Temp\PSL\WebDriver.dll"?
Am I right that only C# Language Bindings are usable in Powershell?
On the selenium Website I found some examples for using a wait in C#. But how can I use these examples for Powershell. I thing I need to create the objects but PS gives me some errors.
Please find the selenium webpage examples below.
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement firstResult = wait.Until(e => e.FindElement(By.XPath("//a/h3")));
What I tried in PS.
$wait = New-Object OpenQA.Selenium.Chrome.WebDriverWait(ChromeDriver, TimeSpan.FromSeconds(10));
-> Doesnt work. My Chromedriver Object is named "Chromedriver".