Using WebDriver in LINQPad is pain

edited October 24
Pain #1: Prevented installing Selenium native web drivers(such as "Selenium.Chrome.WebDriver")

In my previous post(https://forum.linqpad.net/discussion/1680/please-dont-prevent-installing-native-package-in-linqpad), LINQPad added support for installing native libraries, this is good.

But packages like Selenium.Chrome.WebDriver does not provide any AssemblyReferences or native libraries, instead, it provides an exe called "chromedriver.exe" that WebDriver used to do bridge to the browser.



Pain #2: Did not using the ".targets" file in nuget package

This "Selenium.Chrome.WebDriver" provide a targets file to code easily, the file like this:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="CopyChromeDriverToBin" BeforeTargets="AfterBuild"> <PropertyGroup> <ChromeDriverSrcPath>$(MSBuildThisFileDirectory)..\driver\chromedriver.exe</ChromeDriverSrcPath> <ChromeDriverTargetPath Condition=" '$(ChromeDriverTargetPath)' == '' ">$(TargetDir)</ChromeDriverTargetPath> </PropertyGroup> <Copy SourceFiles="$(ChromeDriverSrcPath)" DestinationFiles="$(ChromeDriverTargetPath)chromedriver.exe" SkipUnchangedFiles="true"></Copy> </Target> </Project>

Specifically, LINQPad5 did not respect the BeforeTargets="AfterBuild" field, and not copy anything to "%LocalAppData%\LINQPad\ProcessServer5AnyCPUB" or "%Temp%/LINQPad5/_sgxdmyqf" folder.

LINQPad should copy the "chromedriver.exe" to one of that folder so that I can write code easily and don't need to find where the "chromedriver.exe" is.

Comments

  • Hmm, is there any response for any of this?
  • LINQPad uses Roslyn for compiling queries, not MSBuild. There is no concept of a "project" in LINQPad, and it has no way to parse the .targets file.

    FWIW, this should be fixed in .NET Core 3 (there will be a new version of LINQPad to support this when it's released). It has the concept of a "runtimes" folder where you can put native dependencies via convention-based folders.
  • edited November 2
    Well, sounds a plan, so I guess the best way is switching to Visual Studio for this scenario.
  • If that's the only or main package for which you have that problem, you could work around it by copying ChromeDriver.exe into the LINQPad program folder.
  • That's what I do now, thank you :smile: Still looking for better solution.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!