Selenium tests with Chrome driver on build agent without chrome - c#

We have a set of Selenium tests in c# project with xunit.
We use headless chrome and tests are running just fine on PCs with Chrome installed.
However, on build agents we don't have Chrome, so we receive an exception cannot find Chrome binary.
Is there any way to ship Chrome within test project as a standalone exe, so we don't have to install it on the servers?
Any other suggestions?

There is an option to achieve what you are after, via portable Chromium bundle
within test project as a standalone exe
Basic steps are:
download desired version from their page
unzip
run chrome.exe
Main advantages of the portable browser are that you can carry it with your projects anywhere, avoiding installation and dabbling with the windows registry.
It is true that Chromium is the open-source version of Chrome itself, but is efficient enough just like Chrome. Keep in mind that there are some functionality differences, when it comes to flash and PDF.

Related

How to run Selenium Tests written in C# on a Safari browser in the same Windows 10 laptop

I have written bunch of Selenium tests using C# over .Net/Windows 10 laptop. I want to run these tests on safari browser in the same Windows 10 laptop. I am wondering how do i do that since Safari for windows is no longer available from Apple
Is it possible to
Find a Docker container which can run Safari browser ?
Install a virtual machine of some sort that will run iOS and therefore will have a Safari browser. Then I setup a Selenium Grid hub on that VM and hit the grid from windows maching using C#/Selenium scripts. But I am not sure how to do this
Please advise. Some hints will be useful.
Apple's support for Safari on Windows stopped at 5.1 version, which means the latest safari you can install on Windows in Safari 5.1.
Second - no docker images for Safari -
Third, you can create a Machintosh VM on your PC
here is the link for Catalina
here is the link for Mojave
if you add one of those on your machine you also need to enable Safari automation
1. Open Safari
2. Go to Safari > Preferences
3. Go to Advanced and in the bottom, there is an option "Show Develop menu in menu bar"
4. Check that option
5. Go to Develop
6. Check on "Allow Remote Automation"
7. Close/Quit the browser
After that, you can run the selenium node script on mac in order to connect it from the grid.
And you can also use as a grid the docker-selenium

Selenium headless browser testing using Triflejs

I am having some UI testcases, which are run using a Azure DevOps release pipeline. These testcases are working in Chrome and Firefox when I enable headless mode.
Now I want to enable a headless mode for Internet Explorer(IE11). When I searched on the web I found that this can be achieved using TrifleJs. How can implement TrifleJs in Visual Studio 2019? Can somebody provide the C# code?
Browser : IE11,
Server : Windows Server 2019 Datacenter
As far as I know, IE does not have support for a headless mode.
From the TrifleJs document, the TrifleJs is a kind of browser that can emulate some IE versions in a headless mode and execute JavaScript script, since its coded as a port of PhantomJS.
At present, it is an executable file, instead of a kind of SDK or API, so, we could not directly add it in C# application. I suggest you could check the document to use this tool, and you could also feedback this issue to trifleJS forum

Microsoft webdriver and selenium webdriver causing visual studio build errors

I am trying to use Selenium Webdriver in visual studio to check a website. Everything worked fine when I was using just Chromedriver, but now that I have added the Microsoft Webdriver to test the site using Edge I am having issues. I made sure to download the correct version of the webdriver for my os build.
Every other time I go to run my test visual studio encounters a build error.
Warning Could not copy "C:\Desktop\UnitTestProject3\packages\Selenium.WebDriver.MicrosoftDriver.17.17134.0\build..\driver\MicrosoftWebDriver.exe" to "C:\Desktop\UnitTestProject3\UnitTestProject3\bin\Debug\MicrosoftWebDriver.exe". Beginning retry 9 in 1000ms. The process cannot access the file 'C:\Desktop\UnitTestProject3\UnitTestProject3\bin\Debug\MicrosoftWebDriver.exe' because it is being used by another process. The file is locked by: "Microsoft Web Driver (12804), Microsoft Web Driver (12340), Microsoft Web Driver (1124), Microsoft Web Driver (19756), Microsoft Web Driver (2592), Microsoft Web Driver (12736), Microsoft Web Driver (19604), Microsoft Web Driver (12428), Microsoft Web Driver (18604), Microsoft Web Driver (10500), Microsoft Web Driver (12724)"
If i dismiss the error and then run the test one more time it runs fine. Has anyone ran into this before?
Any help would be appreciated!
Thanks
Check your processes, May be MicrosoftWebDriver.exe is still running in process and that's why you would get build error.
If script fails abruptly, you need to handle your code to quit driver. Otherwise driver will remain active in processes.

Use TeamCity to run Selenium test, but not headless

I have done some research on this, but still confused.
Im using Selenium 3 (C#) with a Chromedriver, Nunit 2.6.4, Visual Studio 2015, TFS and TeamCity 9.
I would like to run a Selenium test, using TeamCity, but I want to physically see the test run. I dont want it to run as a background process. I've seem some say something about running the user agent not as a windows service or to run it manually with some script. But this is where I get confused.
Do I have to add additional code to the project or do it some other way, like a batch file. Or is there another way to run the test in a non headless browser?
Im pretty new to this, so please be gentle.
Thanks in advance.
David
If you are running the TeamCity agent as a service they use a "hidden" desktop and you can't see them run.
You can run the the TeamCity agent as a process by opening cmd as administartor, change directory to BuildAgent\bin and write agent.bat start. Then you should be able to see the tests run. Remember to stop the service first
Go to The agent's service.properties and then set "web.app=true". It will be under the agent directory as "D:\BuildAgent3" if agent is installed on D drive.
Restart your agent..
From Now onwards, you should see the browser running in headful mode.
It worked for us in past, but later on we moved on to a Selenium Grid and hence this setting is not in use for us.
Let me know if it helps..!

.NET Mono .app doesn't launch

So, I started with a compiled .exe file of my program, created in Windows MS Visual Studio, and was able to launch it via Mono by typing mono InkMonitorClient.exe in the terminal. Then I decided to pack it in a .dmg install file. First, I created an .app bundle via macpack. Then I used this github script to create a .dmg image.
The installer works as intended, the window appears in which I can drag my app to the Applications folder, and then it appears there.
But then I'm unable to launch it from the Applications menu in the Dock, although launching it by open -a InkTest or /Applications/InkTest.app/Contents/MacOS/InkTest works absolutely fine.
P.S. The .app file, however, fails to launch by double-clicking and does nothing, but opening it it Terminal (as stated above) works. So, basically, the question is: how to correctly convert .NET (created in MS Visual Studio on Windows) exe file to app bundle.
The macpac tool is for Cocoa# applications, i.e. those built using the Mac Cacoa framework. Unfortunately simply putting an exe built with Win Forms or GTK# does not work, displaying all the characteristics you describe, I have burned hours of my life on that one. See bottom of http://www.mono-project.com/archived/guiderunning_mono_applications/.
If your application comprises multiple .dlls and an .exe you could use ILRepack to package up everything into a single .exe for tidiness. Additionally, it's not ideal, but you could also supply a launcher file (.command file on mac) with your app to save a manual launch from terminal.

Categories