I have to test almost 20 asp.net web application everyday morning to ensure there is no issue in the web sites. so is ther any option to automate it ? There is data entry involved like entering username,password etc.
Note: I will not have the access to the code(only to the applicaiton URL).
Please suggest some option for this, so that we can avoid the manual effort involved in this. Thanks.
Regards,
Jebli.
You should look into web automation tools like WatiN or Selenium.
From the WatiN documentation:
[Test]
public void SearchForWatiNOnGoogle()
{
using (var browser = new IE("http://www.google.com"))
{
browser.TextField(Find.ByName("q")).TypeText("WatiN");
browser.Button(Find.ByName("btnG")).Click();
Assert.IsTrue(browser.ContainsText("WatiN"));
}
}
From the Selenium Documentation:
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
class GoogleSuggest
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
//Notice navigation is slightly different than the Java version
//This is because 'get' is a keyword in C#
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Cheese");
System.Console.WriteLine("Page title is: " + driver.Title);
driver.Quit();
}
}
WatiN and Selenium are Open Source
VSTT 2010 is a good bet.
Example demos
How To: Functional Testing Automation Using Visual Studio 2010 - http://blogs.msdn.com/b/syedab/archive/2010/01/13/how-to-functional-testing-automation-using-visual-studio-2010.aspx
Data Driving Coded UI Tests - http://blogs.msdn.com/b/mathew_aniyan/archive/2009/03/17/data-driving-coded-ui-tests.aspx
Related
I am checking for an alternative of my automation framework that is built in UFT.
I came accross WinAppDriver tool. Looks promising.
But currently getting an error when it tries to launch the application under test-
{"Status":13, "Value":{"error":"unknown error","message":"failed to locate opened application with appid:"XXXXXX.jnlp" and processId:XXXX"}}
The application that i am trying to automate is a Java swing based application.
I tried running a simple java code in IntelliJ just to check whether i can have a quick working sample POC-
private static WindowsDriver appSession = null;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“app”, “XXXX.jnlp”);
capabilities.setCapability(“platformName”,”Windows”);
capabilities.setCapability(“deviceName”, “WindowsPC”);
capabilities.setCapability(“ms:waitForAppLaunch”, “20”);
appSession = new WindowsDriver(new URL(“http://127.0.0.1:4723”), capabilities);
Please help.
Thanks.
I want to log errors for a console application using Elmah.I've found ElmahCore and elmah.io.core but I don't know how to setup any of them on a console app.I'm using .net core.
ELMAH (the open source project) doesn't work with .NET Core. ElmahCore has a lot of dependencies to ASP.NET Core, but if you really wanted to, you could do something like this:
class Program
{
static void Main(string[] args)
{
var log = new MemoryErrorLog();
log.Log(new Error(new Exception()));
var errors = new List<ErrorLogEntry>();
var result = log.GetErrors(0, 10, errors);
Console.WriteLine(result);
Console.WriteLine(errors);
Console.ReadLine();
}
}
You can replace MemoryErrorLog with a target logger of your choice.
The package named elmah.io.core is a deprecated package from elmah.io. elmah.io is (among other things) a commercial cloud version of ELMAH, where you store all of your errors in the cloud (list of differences between ELMAH and elmah.io). elmah.io works with .NET core through either the Elmah.Io.Client NuGet package or using one of the integrations for popular logging frameworks like Serilog and NLog.
I wouldn't recommend you to use ElmahCore for logging in a console application. It is created for ASP.NET Core. There are much better options for logging from a console application, like the mentioned logging frameworks.
We are developing applications in .Net Core and one of them require to access a serial port.
As I learned that System.IO.Ports won't be implemented in .Net Core, I was looking for a nuget library that supplies that functionality, but couldn't get one compatible with .net core (VS Code is showing an error message).
Is there any alternative out there?
UPDATE: I found that the official SerialPort API is being taken into consideration for porting to .Net Core (see https://github.com/dotnet/corefx/issues/984)
I managed to compile https://github.com/jcurl/SerialPortStream for netstandard1.5 with some minor modifications.
Have a look at the pull request: https://github.com/jcurl/SerialPortStream/pull/13
Experimental nuget package: https://www.nuget.org/packages/SerialPortStreamCore/2.1.0
This is now fully cross platform in 2021.
Simply NuGet install either using the command line or your IDE : "System.IO.Ports"
The following example is a .NET 5 console mode program that compiles and works on both Linux and Windows.
using System;
using System.IO.Ports;
namespace PipelinesTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Reading a GPS Device on COM3");
SerialPort _port = new SerialPort("COM3", 4800, Parity.None, 8, StopBits.One);
_port.DataReceived += PortOnDataReceived;
_port.Open();
Console.WriteLine("Press Return to Exit");
Console.ReadLine();
_port.Close();
_port.DataReceived -= PortOnDataReceived;
Console.WriteLine("Ended");
}
private static void PortOnDataReceived(object sender, SerialDataReceivedEventArgs e)
{
SerialPort port = sender as SerialPort;
var line = port.ReadLine();
Console.WriteLine(line);
}
}
}
NOTE: I should have mentioned when I first answered this, you'll need to change the "COM3" in the constructor above to something like "/dev/ttys0" or similar for Linux. You MIGHT also have to run your app as Root/SU on a Linux machine, this is just the nature of Linux's multi user security unfortunately.
I have a problem with opening word document from ASP.NET site. The solution works fine on Windows 2003 Server, but doesn't work on Windows 2008 server x64 and Windows 7 x64.
To simplify the solution I've created an ASP.NET MVC 3 site and try to open word document from there.
Environment I have: Windows 7 x64 and MS Office 2010 x64
The code for opening adocument is the following:
public ActionResult WordTest()
{
var fullFileName = #"C:\inetpub\wwwroot\fpub\TestDocument.docx";
var impersonation = new ImpersonationManager();
impersonation.Impersonate();
try
{
var application = new Application();
try
{
Type documentsType = application.Documents.GetType();
var document =(_Document)documentsType.InvokeMember("Open", BindingFlags.InvokeMethod, null, application.Documents,
new object[] {fullFileName});
try
{
return View(new ModelData {Result = document == null ? "Bad" : "OK"});
}
finally
{
if (document != null)
{
document.Close(false);
Marshal.ReleaseComObject(document);
}
}
}
finally
{
application.Quit(false);
Marshal.ReleaseComObject(application);
}
}
finally
{
impersonation.CloseImpersonation();
}
}
Firstly, I make impersonation to use trusted domain user account for word interaction (ImpersonationManager is a custom component). This user has rights to open\save\close Word Application. In my tests this is my own account :)
Then I create Word application instance. WINWORD process is started under impersonated account.
But after "Open" method is invoked it always returns null. No exceptions, no info in event viewer.
Moreover Word process loads the CPU on 100% after this (1 core of CPU).
If I run the same code (without impersonation) as console application it works fine.
I wonder what can be the problem here?
Update It works fine if Visual Studio Development server is used as host for the site
Using Office interop in a server-scenario (like ASP.NET, Windows Service etc.) is NOT supported by MS - see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
Additionally there have been several security-related changed since Windows Vista which basically make it really hard to do anything "desktop-like" in a Windows Service (IIS/ASP.NET is just a special case of Windows Service in this regard).
There are several libraries (free and commercial) to deal with Office files (without Office Interop)... to help further you need to describe your goal.
Regardless the accepted answer some people need to support legacy code. The solution to the problem can be found here: http://social.msdn.microsoft.com/Forums/en-US/0f5448a7-72ed-4f16-8b87-922b71892e07/word-2007-documentsopen-returns-null-in-aspnet
I need a Continuous integration tool that will support both .Net Unit tests and Javascript unit tests and perform the builds.
It looks like my main options are CruiseControl.NET using JUnit and NUnit or Team City and JS Test Driver.
Are there any other options and which ones have you used or had good or bad experiences with.
thanks
+1 for CC.Net here. I use a combination of CC.Net and NUnit & Selenium for UI testing. CC.Net allows you to do everything you require and it's a doddle to setup.
You can write custom modules to allow you to do things such as incremenet build numbers and modify config files on the build server.
You can happily use a combination of unit tests and Selenium to test the UI using a test such as the following:
[TestFixture]
public class UITest
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("server", 4444, "*iexplore", "http://server/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[Test]
public void TheUITest()
{
selenium.Open("/RecipeProfessor2/");
selenium.Click("btnTest");
selenium.Click("Button1");
selenium.Click("ctl00_ctl06_toolBar_Home_Solve");
selenium.Click("ctl00_ContentPlaceHolder1_chkIsLive");
selenium.WaitForPageToLoad("30000");
// etc
}
}
You can obviously add in as many tests you require for either standard unit tests or UI tests.
How about something like:
http://www.niltzdesigns.com/blog/2011/04/08/adding-javascript-unit-tests-to-your-continuous-integration-scripts/