So here we go with second part for automation. Hope you liked the first part
In previous part I demonstrated a very small part of automation. I also said I will use c# for demonstration you can use java and I will try to cover other languages as well. I will post one more topic to use c# as your automation language and will tag the link here
As we see in last post automation testing is not sodiffuclt but just a matter of bit understanding and integration of windows and its APIs (tough, but will not be). Anyone can be automation engineer without using any framework. So I am going to continue the same example here and will add few more lines of code to make your own framework.
I will add few logging and some validation to my previous example
ie.Navigate("http://www.google.com");Log.WriteLine("google.com launched");
// Store HTML Document object
doc = ie.Document
// Find Text Box and input text
HTMLInputElement searchTxtBox = doc.GetElementsByID("gbqfq");searchTxtBox.Value = "Automation Testing";Log.WriteLine("Automation Testing is entered into searchbox");
// Find Search Button and click
HTMLInputElement searchButton= doc.GetElementByID("gbqfba");
searchButton.Click();
Log.WriteLine("Clicked on search button");
// validation, I am expecting here 15 search result at least
In previous part I demonstrated a very small part of automation. I also said I will use c# for demonstration you can use java and I will try to cover other languages as well. I will post one more topic to use c# as your automation language and will tag the link here
As we see in last post automation testing is not sodiffuclt but just a matter of bit understanding and integration of windows and its APIs (tough, but will not be). Anyone can be automation engineer without using any framework. So I am going to continue the same example here and will add few more lines of code to make your own framework.
I will add few logging and some validation to my previous example
HTMLDocument doc = new HTMLDocument();
InternetExplorer ie = new InternetExplorer();ie.Navigate("http://www.google.com");Log.WriteLine("google.com launched");
// Store HTML Document object
doc = ie.Document
// Find Text Box and input text
HTMLInputElement searchTxtBox = doc.GetElementsByID("gbqfq");searchTxtBox.Value = "Automation Testing";Log.WriteLine("Automation Testing is entered into searchbox");
// Find Search Button and click
HTMLInputElement searchButton= doc.GetElementByID("gbqfba");
searchButton.Click();
Log.WriteLine("Clicked on search button");
// validation, I am expecting here 15 search result at least
HTMLInputElementCollection numberOfLinks = doc.GetElementByID("ires")).GetHTMLInputElementsByTag("li");
if (numberOfLinks.Length >= 15)
Log.WriteLine("PASS");
else
Log.WriteLine("FAIL");
This is done! Isn't it? Yes I know this is not workable becaues I haven't provided any other steps, like how to start, what is Log and from where I referenced InternetExplore etc etc. But don't worry the automation is just it. Nothing special in concept wise, either I can make this a exe file or a dll or a jar file and I am ready with one test case automated.
I know still you would have many questions like we get QTP a record button and Visual Studio a record button, in fact many framework provide the same. So how can we find out the buttons, text boxes, links etc. Believe me there are many hidden treasures in Windows and Browsers which usually ignored by many people. I will reveal those treasures so that you no more needed to depended on framework, but you can make your own.
I would request a few things before we continue our test automaiton journey. I would preffer to install Visual Studio or C# from this link. I will also post in java but on windows I preffer in c# more appropriate.
Here are some samples of writting Console Application in c#, you can also learn VB.NET or any other language which supports Visual Studio. But my recomendation is C# it is hotcake for windows automation. http://www.dotnetperls.com/console
I will wait for the feedback.
I know still you would have many questions like we get QTP a record button and Visual Studio a record button, in fact many framework provide the same. So how can we find out the buttons, text boxes, links etc. Believe me there are many hidden treasures in Windows and Browsers which usually ignored by many people. I will reveal those treasures so that you no more needed to depended on framework, but you can make your own.
I would request a few things before we continue our test automaiton journey. I would preffer to install Visual Studio or C# from this link. I will also post in java but on windows I preffer in c# more appropriate.
Here are some samples of writting Console Application in c#, you can also learn VB.NET or any other language which supports Visual Studio. But my recomendation is C# it is hotcake for windows automation. http://www.dotnetperls.com/console
I will wait for the feedback.
No comments:
Post a Comment