Some basic understanding questions about using DLLs

Welcome Forums General PowerShell Q&A Some basic understanding questions about using DLLs

  • This topic has 5 replies, 2 voices, and was last updated 1 month ago by
    Participant
    .
Viewing 5 reply threads
  • Author
    Posts
    • #258008
      Participant
      Topics: 6
      Replies: 20
      Points: 22
      Rank: Member
      Hello all,
      quite some time has passed since my last post :).
      I’m trying to use some .Net dll in Powershell and having some knowledge gaps there which you might be able to fill.Basically I’m trying to automate a Werbbrowser using selenium. I found an nice blogpost about it https://tech.mavericksevmont.com/blog/powershell-selenium-automate-web-browser-interactions-part-i/.
      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:
      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”?
      3) Also I found several different “Language Bindings” on the Selenium website. What are “Language Bindings”? https://www.selenium.dev/downloads/
      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.

      What I tried in PS.

      -> Doesnt work. My Chromedriver Object is named “Chromedriver”.
      Best Regards,
      Baschi
      • This topic was modified 1 month ago by grokkit. Reason: code formatting
    • #258011
      Participant
      Topics: 6
      Replies: 20
      Points: 22
      Rank: Member

      I’m aware of the selenium module in Powershell, but I try to get a better understanding of using DLLs in Powershell.

    • #258056
      Participant
      Topics: 1
      Replies: 85
      Points: 387
      Helping Hand
      Rank: Contributor

      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?

      You could do the following after you load the assembly:

      2) is there any other way to load a dll besides Add-Type -Path “C:\Temp\PSL\WebDriver.dll”?

      Add-Type is the easiest and most recommended way that I have found.

    • #258059
      Participant
      Topics: 6
      Replies: 20
      Points: 22
      Rank: Member

      Hey guys,

      managed to collect some knowledge from the Selenium Module implementation.

      Also I found a website which is explaining how to use the different classes of the DLL. Are those kind of documentations the only way to get that Info?

      I learned now hot to work with the different classes but questions 1,2,3 are still unanswered to me.
      best Regards,
      Marcel
    • #258062
      Participant
      Topics: 6
      Replies: 20
      Points: 22
      Rank: Member

      @AdminOfThings45

      Thanks for you reply, seems we send it at the same time. Will check :).

    • #258065
      Participant
      Topics: 6
      Replies: 20
      Points: 22
      Rank: Member

      That was very helpful thanks.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.