I am using C# WebDriver to automate a web application. Everything is written targetting Windows already. But now there is a need to get it ready for Mac as well. Selenium webdriver launches Chrome using ChromeDriver.exe. This exe can be launched in Windows using C# Process class; but not in Mac using the same class in Mono. The solution seems to be building ChromeDriver in Mono. I have got the ChromeDriver source from github. But having difficulty in building the same.
The problem statement is: how to build ChromeDriver.exe with Mono. I am using Xamarin Studio (which is the Development IDE I am using to develop in C# on Mac). So my aim is to load the ChromeDriver sources in Xamarin Studio and build it. But when I pulled the sources of ChromeDriver, I see several C files without any project file, as in *.vcxproj. Searching on this topic what I find out is that it could be built using Ninja. There is some command "ninja -C out\Release chromedriver" that is going to do it for me. So I fetched the Ninja sources from github. But when I try to run the build command, then it complains out/Release File or Directory not existing. It is indeed not existing inside the folder where I fetched Ninja. The only information I have is that the out folder will be there once I generate the Ninja files. But I am completely ignorant about how to do it or what are the pre-requisites for it.
Coming back to why I need it: In the selenium webdriver code the ChromeDriver is launched using C# process class.
Process p = new Process();
p.StartInfo.FileName = <Full Path of ChromeDriver.exe>;
p.UseShellExecute = false;
p.Start();
This C# code snippet works in Windows, but not on Mac. I use Xamarin Studio to debug it. And the error I get at the line p.start() is "No process attached to the object p". Next I build a simple console application in C# using Xamarin Studio on Mac; i.e. the output exe is built with Mono framework. And I use this exe's path instead of ChromeDriver in the above code. And p.Start() gets executed successfully with no error.
Hence the problem comes down to having a Mono version of the ChromeDriver.exe. In chromedriver's site they have ChromeDriver.exe for Windows, ChromeDriver.dmg for Mac but no Mono version of it. I am looking for any of the 3 following solutions:
1. If the ChromeDriver.exe built with Mono is already there somewhere uploaded, nothing better that that.
2. The steps I can try to build the ChromeDriver sources
(https://github.com/scheib/chromium/tree/master/chrome/test/chromedriver)
with Mono.
3. Skip building it altogether and find some other way to launch the ChromeDriver.exe in Mac.
I am scratching my head with all these for the last couple of days :( . Any help will be largely appreciated! Do let me know if any more info is required. Please help..
Thanks in advance,
Deb
sorry for being absent for a year! Really appreciate your concern.Yes, finally I was able to do it. Downloaded the Mac version of chromedriver from http://chromedriver.storage.googleapis.com/index.html. And simply used it in my C# (mono) code written in the Xamarin Studio. And I was able to invoke the ChromeDriver using the usual "SeleniumDriver = new ChromeDriver(driverLibrary);" statement. But I had to make some more changes in the C# code at multiple places to make the entire Automation framework work on Mac. I forgot the finer details but remember it was fun! People were excited to see Webdriver+Mono doing it on Mac!
Related
I am using Visual Studio Community 2022, and I was wondering if you could use another CLI to run/debug a c# console application. (I can't use cmd.exe or powershell because it's blocked by the admins of the device I'm using). Git Bash would be preferred, because it's already installed. Thank you!
Edit: Looks like you can't do this. dotnet run just tries to open the blocked binary, no matter where you run it. I think the admins hate everyone though because they allow you to install lots of things (like Unity, vscode, etc.) but running anything just doesn't work.
Thanks for trying everyone!
use this to run your program in CLI but you cannot debug it if you want to debug use debugger mode of vs2022,
If it's a framework-dependent application (the default), you run it by dotnet yourapp.dll.
Run the project in the current directory:
dotnet run
check Microsoft Docs dotnet run for more options.
CLI: Use Vs2022 Terminal in View->Terminal it may help You to run it.
Basically, my school only has Mac computers, however they're telling me to learn C# and to do so using Visual Studio. However, the school program is fairly new and the projects are self-guided. I've been coding in C# using Visual Studio and it's been working so far - it's run successfully and everything. However, I can't seem to find a way to export or publish my code into a standalone application. I've tried using WineBottler to convert the .exe into a .dmg, but I can't seem to make it work.
How should I do this? Moving to Windows or another IDE/compiler isn't an option. I've currently been creating my projects in a Console App, but I could change that if necessary.
After quite a bit of experimentation and research, I've found that while you can publish a .NET Core Console App within Visual Studio for Mac, the feature is not supported within the GUI of the program (for whatever reason).
In order to publish, you have to Control-Click on the solution in the Solution Explorer and open the project in the command line by clicking Tools > Open In Terminal.
Once there, type in the command:
dotnet publish -c Release --framework netcoreapp2.1 --runtime osx-x64
This will create a self-contained program for 64-bit mac os on the v2.1 .NET Core framework. The runtime can be changed for different operating systems and the version number for netcoreapp can be changed based on which version you're using and what is compatible with any plugins for your program.
The final product will be found in yourprojectfolder/yourprojectname/bin/Release/netcoreapp2.1/osx-x64/publish
You should have no issues creating and compiling .NET CORE console apps using a Mac. These apps will have limited .NET functionality, do not have .exe files, and are platform agnostic. Here is a quick guide you can reference to decide if .NET CORE is the right option for you.
If you are trying to create WinForm apps or something similar, you cannot do this on a Mac. There are "work arounds" using Wine or other tools, but my experience with those options has been suboptimal at best. If you need to create apps like this, then your best option is to program on a Windows machine. Perhaps ask your school to enable bootcamp and install Windows 10 OS on one of the Mac machines.
You can generate exe using the terminal if you are on OSX. You can follow this post
It requires :
Visual Studio For Mac
A .cs file
Few lines in terminal
I have developed a project with VS on Windows 10. Right now on Linux mint i am debugging the project with MonoDevelop and it runs just fine.
Let me show you:
However when i make a build and i go to the Release folder and then i try from the terminal to launch the program i have a problem. Let me show you first the files i have build:
Then i go to the directory with my terminal and i run:
chmod +x ./WorldServer.exe then i run ./WorldServer.exe
and i receive the following error:
I know that this is .exe file and maybe i have to build a different type of file. But i am not really sure what setting should i apply in my project to make a working build for linux.
As far as i know linux is using .so as extension for it's libraries. However it is generating .dll files. Can i change that? Can i somehow make my project to be "buildable" in the two OS Linux and Windows ?
The exception tells us, you need System.Management in your project. It isn't there.
Why?
Because Mono, according to there Road-map, doesn't support this:
The following do not map to operating systems other than Windows, and
we are unlikely to spend time to support them even on Windows:
System.Management
How?
System.Management is a library that only works on Windows. The MySQL connector driver has started to depend on this library and tries to load it per reflection.
I'm not into this whole MySql Progess but there is an open bug for it. Also there is a comment which says:
The last working version of the MySQL .NET Driver is 6.4.6
I hope this helps you.
First of all, im not sure if there is a specific forum thats more suitable for request about Jenkins, but I figured I just post it here.
So, I have this C# project, it right now requires Visual Studio 2015 to build and I would like to automate builds with Jenkins. This is the first time I'm using Jenkins and I was able to set it all up, it fetches the code from the gitlab repository, but right now there is no build action configured. For "fun" i tried to simply make it use a "windows batchfile" as build file and added echo test. Checking the console output it downloads the repository code and then tries to execute the batchfile, result is:
java.io.IOException: Cannot run program "cmd" (in directory "/var/lib/jenkins/workspace/Project"): java.io.IOException: error=2, No such file or directory
This of course makes sense, but I wonder now, is there a way to build a C# project with jenkins on a debian server without resorting to mono or something? I know that people build C++ projects for windows with Jenkins on a linux root, so there has to be some sort of cross compiling possibilities.
If the Visual Studio 2015 is a dealbreaker I can also strap it down to VS13 or even below. Any help is greatly appreciated!
/EDIT
Its probably important to say that Mono is NOT an option. Im using features like WPF that are not available for Mono.
Use Jenkins' MSBuild plugin.
Jenkins.NET is a good blog about using Jenkins in a .NET environment. First post is here.
I have a c# program I wrote. I want to run it on Mono on CentOS 6. What are the steps I need to take to compile it? I read some steps using xbuild which I could not get to work, some steps using gmcs, etc. Nothing working right now.
A simple and to the point guide would be good. I ran it through a Mono Analyzer and it did not give any errors for Mono, so it should be good to go.
Well you shouldn't have to special compile it at all as long as it doesn't have a GUI (meaning it's just a console app), or that GUI is a simple Windows Forms or GTK#. Mono will run a regular C# program on the console just fine. There is some quirkiness with Windows Forms, which was never fully finished, but generally you should just be able to compile using VS 2010, copy the dll's and executables to the system you want to run it on, and run 'mono myprogram.exe'. We run several older programs we have this way.
To run a .net program under mono all you have to do is to copy the .exe file with all depending dlls to the mono machine and run the application with:
mono myprogram.exe
if this doesn't work, something with your code doesn't work with mono/Linux.
As you mentioned in a comment, you got some IO errors, that could be because you trying to connect to COM1 or something like that. COM doesn't exist in Linux, as I'm sure other stuff doesn't either (I'm a very beginner with Linux ^^).
Maybe you should try to Console.WriteLine() at some points off your code. That's a good way to "debug" without debugger ^^