Setup web server when using selenium webdriver c# - c#

Im using selenium webdriver to make behavior tests on ASP.NET MVC application (C#).
I want to have a server that will automatically open when I run those tests, like the IIS server which automatically runs when I debug my application.
How do I do that ?
BTW, Im using the ChromeDriver if that matters.
Thanks.

Have you seen Stephen Walther's post which explains how you can create integration tests for ASP.NET MVC applications by using a combination of Selenium WebDriver and IISExpress?
http://stephenwalther.com/archive/2011/12/22/asp-net-mvc-selenium-iisexpress.aspx

Related

How can I automate testing of a non-automation enabled desktop application

How can I automate testing of a non-automation enabled desktop application using Appium, WinAppDriver, Visual Studio, and C#? The application is not showing any XPath or other identifying elements. Are there any techniques or methods that I can use to enable automation support for the application and allow me to perform automation testing?
I am using Appium version 1.17, WinAppDriver version 0.7, Visual Studio 2019 and C# to try to automate testing of a custom built non-automation enabled desktop application. The application is a accounting software with custom functionality.
I have tried to locate identifying elements or XPath of the application by using inspect.exe but it did not find any xpath or identifying elements. I also tried to enable the automation support but it was not successful and the application was not responding.
I am getting the error "element not found" when trying to interact with the application using Appium and WinAppDriver.
Any suggestions to automate this application using the above mentioned tools would be highly appreciated.
I personally use appium inspector that you can find going to this link.
https://github.com/appium/appium-inspector
You will need appium server running to get this working.

Run Angular from C# - NUnit testing

In the solution we have an API, Angular app and NUnit tests project. I have the task to test the UI of the angular app from NUnit test. Is there a way to run angular app from the setup of the test?
You can use Selenium WebDriver for those purposes. If it is configured correctly, you will be able to open a new web browser inside your NUnit test and check the Angular app there.

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

How To Open Localhost With Selenium - C# .NET

I'm testing a .Net exe web application on my local machine using Selenium web driver in Visual Studio. To view the web UI I need to open a firefox browser and connect to http://localhost:12345
When I run this code
driver.Navigate().GoToUrl("http://localhost:12345");
a browser opens but just sits blank. Then I eventually get this error in VS:
'OpenQA.Selenium.WebDriverException : Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055'
When I run the same test using Selenium IDE Firefox opens http://localhost:12345 correctly.
How do I get Firefox to open the localhost address I provide it in my C# code?
Thanks for taking the time to look at my question.
I have managed to find a solution which I will post here for anyone who encounters the same problem.
In order to access localhost I used Selenium Standalone Server instead of Web Driver. These are the steps:
1- In class under [Setup] enter
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:12345/");
selenium.Start();
verificationErrors = new StringBuilder();
}
2- Download Selenium Standalone Server
4- Run Selenium Standalone Server using cmd java -jar selenium-server-standalone-version-number.jar
5- Run test in Visual Studio
And now it works.

Integration of automated testing in hudson using selenium framework

I'm new to web development and web testing. And I want to use Hudson in my continous integration and for my automated testing using selenium. How can I integrate the selenium in hudson, so that everytime I build using hudson, it will automatically execute the automated testing in selenium? What application should I install? By the way I'm using ubuntu as my OS.
I'm building my webapp using asp.net and C#.
Please advise.
Thanks.
You would invoke the tests like you would for your normal unit tests. Assuming that you are creating your tests to be run with NUnit then you will need to make sure that that is installed.
Setting up your Selenium project, like a normal class library project, that builds a dll that can run your tests should suffice.
You can Integrate your Selenium-TestNG/Nunit Framework with Maven, Maven build path you can give in Jenkins/Hudson.

Categories