Saturday 11 November 2017

Code to save IWebDriver.PageSource in XML file

The Following snippet is most of the time used while working on Automation using WinAppDriver


driver - RemoteWebDriver instance


System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(driver.PageSource.ToString());
System.Xml.XmlTextWriter writer = 
     new System.Xml.XmlTextWriter(@"c:\App_To_XML.xml", 
                   new System.Text.UnicodeEncoding());
writer.Formatting = System.Xml.Formatting.Indented;
doc.WriteContentTo(writer);


-Pankaj Dhapola
Let's Think on it

Sunday 1 October 2017

Why I think Psychology subject should be taught along with Computer Science

Continuing with the previous discussion

I argued Sam bhai that give me any automation tool or any software language to work upon and give me sometime, I should be able to start working on it easily!

He said "Anyone can do it, we have plenty of Tutorials available".

I said "But some of the proprietary tools don't have tutorials, apart from company's documentation and Limited Forum how you can excel at such tool?"

He has a suspicious look! and exclaimed "And on what basis do you say that with limited educational material you would be able to crack it up?"


Filling over another glass full of beer I said "Psychology and Behavioral pattern of the machine"

Stunned Sam bhai had this sense of understanding in his eyes and said "Go ahead! I would like hear more".


Lets not talk about the Human Psychology, its too complex to Understand. Psychology of machine is fixed and simple. Can be complex sometimes and that too depends on the creator of machine, one should bow to Creator of Matrix in Matrix Movie. You give an input to a machine/software and receive an output. Let me be a little metaphorical over here.

I believe if you want to be a good programmer, step into the shoe of compiler, think like a compiler and present the output like a compiler. It like being a compiler you will have to respond to each line of code according to the rules set by creator. Thinking like machine\compiler compelled me to say machine do have per-defined conscience.

I meant What do a psychiatrist do? He evaluates you by calmly listening you, ask you certain questions or sometimes ask you to share whatever you want. Let's take it at a minute level, its plan and simple stimulus-response pair. Can we relate this to machine as Input-Output pair?

Likewise if you want to be good programmer start evaluating the tool, start sending input code, remember the output, yeah it complains too i.e. error, and during the middle of conversation clarify some doubts i.e. put a breakpoints and check the value of a variable ;)

Imagine a java compiler as culmination of various great programmers in Sun microsystem (now Oracle). While creating compiler the compiler designer must have thought, let me code this way such that whoever is going to use this compiler will send such input and the output is provide in such format.

In short you can think that a compiler is actually a replica of the Programmer's Mind.

Can we think in this direction to Introduce Psychological Compilers (of-course with good conscience) where the future AI will behave in a predictive pattern.

-Pankaj Dhapola
Let's Think on it

Why an organization should not let anyone to code Automation Script

On Sep 17, 2017, I had a great discussion over couple of beer with one my good friend Sam (though he drinks sprite only) :D


Now we were discussing about latest trend in Software Test Automation, since I have been exploring on subjects like WinAppDriver, Galen Framework, XML based API Testing. After exchanging little ideas about these tools Sam came up with a new tool which is being currently been implemented in his company. Let me not name the tool, lets say it "Automation tool for Kids" or ATK.Why I named it that way, you will come to know, please proceed.

Sam is kind of high caliber Automation-cum-Software Developer.

Sam bhai told me this tool is awesome. He went for 5 day training for this tool. He said anyone can work on ATK. No need of in-dept knowledge of JavaScript or any other language.

I raised my eyebrow. How is that possible?

He went on explaining me why this tool would be a success. His company have asked manual testers and BA's to start working on this tool. I asked him about the test stability. He said he don't have the data yet but he was quite positive about less maintenance in regression suite.

One thing that has always bothered me is the Test Stability. Please understand my frustration, I have been working on Automation Testing Profile for around 8 years and have little good understanding of QTP/UFT, Selenium WebDriver, Test Complete, Coded UI and most of the time I have been working on Fixing the issues in Automation and I know exactly where an automation code will/has fail/failed.

Having this things in my mind I was kinda skeptical about the Test Stability. In my organization, we have got this great tool - basically a wrapper of Selenium WebDriver and nicely build. Just like any Keyword driven framework you just have to pass on the locator and data. Trust me I never faced an issue related to the code behind of this Keyword Driven framework based tool, nicely coded, nicely synchronized and very nicely configured.

Now where did the issue started. The basic issue was at the inception of this tool, it was targeted for Business Analyst and Manual Testers to write the scripts. Problem is when you ask a non-technical guy to code the automation script it will be easy for them to add steps like "ClickOnAnElement", "EnterAValueInAnElement" or "ValidateAValueIAnElement" but 
- What about the Synchronization?
- What about the correct Identification criteria or correct Locator? 
- What about the behavior of system?
- What about different ways of Validating a result?
- What about code re-usability and maintainability?
- What about scalability?

Without an understanding of Automation Framework Development, it would be unfair to expect good stability in Automation Suite. It doesn't matter which automation tool you use.

-Pankaj Dhapola
Let's Think on it