Posts tagged as:

framework

The quality engineering has gained the popularity as same way as software design and development and sometime more than some of the development technologies; as it is required for most of the application /systems. As being most recognized company in Quality engineering, we observed that most of the companies will have quality engineering department of their own even-though the software development is out sourced to other vendors.

Now a days, software test engineering (QA) is not just limited to test case managements with tools like QMetry etc. and test execution manually. But there are many areas like test automation, performance / load testing, security testing, SOA testing and code review with testing etc. being introduced and widely used by each departments at different level. In all of this, the test automation is very much popular as it reduces the regression test duration plus easily integrated with continuous build systems etc. to result in best ROI over the time.

There are many automation tools available which can be used by any manual test engineer for regression tools like Selenium IDE, Sahi etc.. Still once you start the automation, there will be  some more demand  from your QA Manager / Test Lead / Project manager / CTO about test results, debugging, reusability, continuous integration, maintainability, execution from cloud etc. and that will required you to develop the framework using scripting language / programming language.

Amongst big group of automation tools, selenium is the only tool which supports many programming languages ranging from simple  like HTML to complex like Ruby/Java/C# to automate the test bed of your web application. As selenium supports variety of languages for automation, manier  get confused to select the suitable language for automation. Mainly the selection of laungage depends on many different crieterias as well. Therefore  to overcome from this delta situation, I tried to get input from different big players in automation world about the preferred language and based on which crieteria they select that etc. We had run the poll for same for quite a month long time and able to get good information as descried in following sections of this post.

Overall Result:

Language preferred for Selenium Test Automation Project? Write in comment for other languages.

Language preferred for Selenium Test Automation Project? Write in comment for other languages.

We can see that JAVA got around 77% votes from total 194 votes worldwide.  The HTML, PHP and Javascript etc. was not part of selection but few peoples are using this for their test automation.

We have got some language selection criteria based on the feedback during this poll are:

  1. SUT development environment
  2. Open Source Tool
  3. Material/libraries available for language
  4. Performance and Transaction Time
  5. Easy to code, IDE
  6. Language exposure to automation engineer

Etc.

If we have to rate these criteria’s, then the first point will win the race and most of has voted based on this criteria.

Brainstorming: Based on first preference and poll data, can we think that JAVA is most popular in development as well!!

The consolidated feedback and related information is as below.

1. SUT development environment

Many time, we (auto architects) think to use the language as same as the application under test development platform/language. Because it help us to use the same tests as unit tests and helps us for customization etc.

“I prefere Python because I like this language and I used if for wide range of tasks before I start automation with Selenium. Python has everything what I need for any purposes. But Current project based on PHP, so one of requirement was that automation will also based on PHP” – how can you leave your preference.

Helps in unit testing – “ Being able to write Selenium tests in JUnit allows me to do end-to-end testing of our server-side Java application and browser clients. So I can call into a backend Java application(handy for me when doing test setup and cleanup) and control the browser from the tests. I can also easily take automated screenshots of the browser view.”.

Further from other expert, “It really depends on what your goals are. Personally I prefere using the language the app is written in. Of the benefits its nice to be using the same language and tool chain the developers are using to make collaboration and integration points simpler.”

Manish says, “I’m working in a product that uses Selenium RC with C# and codedUI and I’m enjoying it and the reason of choosing c# is the same app written in .Net”

More specific quote “For your tests to be economically maintainable, they need to be in a Turing-complete language (e.g. not HTML-based). That said, assuming either: 1. There’s no dedicated QA team and testing is an integral function of Development or 2. there’s a dedicated QA team that works closely with development, the only responsible choice for your scripts is in the language of the application under test. Otherwise, cooperation with Development for test case issue resolution will be difficult as not all members may be familiar with the script language.”

2. Open source Tool

We all know that why JAVA won the race, because it is open source.

“Eclipse with JAVA and selenium is free, however .NET IDE is not free. There is an open source .net IDE called mono that could be used with selenium;”

Ratankumar adds “ I’d prefer JAVA, as it is also open source and easily available for download.”

3. Material/Libraries available for language

The availability of the documentation / samples / tutorials can matter the selection of the language for your selenium (others as well) automation projects very well because not all test automation engineers / architectures will have strong programming language experience. So this type of supporting material helps them for quick start. Selenium is the very best automation platform which gives us the wide variety of language selection for automation and which make ease for the new people to quick start with the help of this kind of supporting material.

“I favor Perl because I can use the martial from CPAN.org to build a framework. I have lot of modules that I can interface to the selenium api” – Perl selection for automation based on this criteria.

Kshitij describes in same line “ I prefer java/junit with Eclipse, due to easy available solution on web and most other plugins and technology for automation is available in Java.. So its easy to integrate with selenium.”

C# Documents seems ahead of all, “ C# has a ton of documentation and tools that can complement your script development efforts.”

Do you think same “ There’s much less user support for Perl, but having that extensibility opens up many avenues. I’m looking forward to checking out the Webdriver Perl bindings.”

4. Performance and Transaction times

Sometimes we think on this before starting the automation development.

Selenium can perform well with Java. Do you agree with “Selenium is built on JAVA and runs through a JVM. So I suggest using the language that selenium was created in.”

5. Easy to code, IDE

Definitely this is the easiest criteria as well, but test automation sometimes required customization in results presentation, looping based on data etc. So I am not sure that whatever language we will define as “easy to code” will be good selection for test automaton. Still we can find some other supporting interfacing language etc. like HTML is very easy so try to use Java Script extensions with this will definitely help you to keep it easy to code plus some level of customization. Let me describe same thing in users’ words: “I prefer html tests/cases with selenium server + js extentions + Hudson”.

Also, IDE does matter in the selection as it helps us to make our coding with easy due to context sensitive help, auto complete etc. C# IDE Visual Studio, Java IDE Eclipse etc. are good IDEs and is important point in language selection decision making process.

“If you have access to the VisualStudio IDE you cant go wrong with that”. I like this.

6. Language exposure to automation engineer

Sometimes we do not disclose or mention this criteria, but I think it is always get hidden consideration for language selection.

Are you thinking same? “I personally prefer Java because that’s the language I’m most familiar with. However, if the project and its timeline provided the opportunity for my learning curve, I would love to try out some other languages – it for nothing more than to see what differences there are.”

Anand is asking us with explanation, “Depends on which language you are already comfortable in, isn’t it? If you are comfortable in JAVA you don’t learn PHP to write selenium tests. As far as I know, most of the bindings provides the same features. And thanks to people behind Selenium for making this possible !”

In short, all points has their own pros and cons but this poll has created a platform to help someone to ask related queries to other who using same language.

At last, thanks to all for voting and commenting. We will come up with something similar and useful topic again!! 

courtesy:

  1. Selenium Automation User Group
  2. Infostretch Selenium Test Automation Framework
  3. All the linked in users who voted and commented on poll : “Language preferred for Selenium Test Automation Project? Write in comment for other languages.”

Thanks and Regards,

Akhilkumar Patel

Waiting for your suggestions and queries!!

 

 

VN:F [1.9.10_1130]
Rating: 9.0/10 (3 votes cast)

  

{ 0 comments }

For non technical testers Selenium IDE is the ideal environment for creating Selenium tests. Selenium IDE provides code formatter for different language and/or testing frameworks.

Choosing the right framework or scripting technique helps in maintaining lower costs. The approach of scripting used during test automation has effect on cost due to development and maintenance efforts.

Various scripting techniques are generally used when developing test automation scripts are:

  • Linear : Procedural code, possibly generated by tools like Selenium IDE
  • Structured: Uses control structures – for instance ‘if-else’, ‘switch’, ‘for’, ‘while’ conditions or flow control statements
  • Data-driven: Data is persisted outside of tests in a database, csv files, or other mechanism
  • Modularity-driven: Creation of small, independent scripts that represent modules, sections, and functions of the application-under-test
  • Hybrid: Two or more of the techniques above are used

Adding Functional programming capability to IDE

If you are using selenium IDE for developing your tests, then using InfoStretch Selenium IDE plug-in you can record scripts that turn out to be Structured, Data-driven, and Modularity-driven or Hybrid. Plug-in provides code formatter to export recoded steps in IDE to “InfoStretch Test Automation Framework (ISFW)” format. In addition to code formatter for ISFW, following functional programming capability added to IDE:

  • Defining reusable steps as modules
    • supports parameters
    • can return value
  • Call defined modules in tests
  • Conditional Flow control
  • Looping
  • Nested looping and conditional flow

Through InfoStretch plug-in you can apply different approaches while recording using selenium IDE, for instance

  • Scripts generated by Selenium IDE using record facility be the linear
  • By use of control structures commands – typically ‘if’, ‘else’, ‘elseif’, ‘while‘ conditions/ statements provided by InfoStretch plug-in will make scripts Structured
  • Creation of small, independent modules of the application-under-test using ‘defineModule‘ command provided by InfoStretch plug-in be useful in developing Modularity-driven test
  • Call command provided by InfoStretch plug-in be useful call defined modules in test
  • Define module with parameters and use of data-provider will make script Data-driven

Thus three steps for non technical users are:

  1. Record using Selenium IDE
  2. Edit as per requirements
  3. Export test case as “ISFW” format from IDE.

You can get more detail about plug-in usage in next blog “Using InfoStretch Selenium IDE Plug-in”

VN:F [1.9.10_1130]
Rating: 9.8/10 (11 votes cast)

  

{ 2 comments }

InfoStretch test automation framework provides test page concept in a best efficient way by which you can manipulate page navigation same as on actual web application under test. Once page get created page objects/functionalities can be used in any test case, makes code more reusable. The framework takes care of not only launching that page but the entire page hierarchy to reach that specific page. Furthermore it also checks that is page already active in browser? If so then it will continue from there, results in reduced execution time.

Following are two of the test cases that demonstrates

  • Reusability of code
  • Reduced execution time
  • Less maintenance

As the class the derived from framework’s base class, test case developer only need to concentrate on writing the tests and not spend time on adjusting the underlying framework.

      @Priority(value = 1)
      @Test(enabled = true, groups = {"BulkUpload", "Supplier", "Report"},
      description = "TC4277: Verify that 'Upload Status Report' link is visible to buyer on 'Supplier Upload Status' page.")
      public void TC4277() {
            String jobid = context.getAttribute("upload.jobid.TC4277").toString();
            UploadStatusPage statusPage = new UploadStatusPage(getSTB());
            statusPage.launchPage(jobid);
            getSTB().assertElementPresent(UploadStatusPage.UPLOAD_STATUS_REPORT_LINK_LOC,
                        "'View Report' link");
            getSTB().verifyIsVisible(UploadStatusPage.UPLOAD_STATUS_REPORT_LINK_DIV_LOC,
                        "View Report link");
      }

Commands executed in selenium. You can see commands executed for the entire page hierarchy to reach that specific page.

getNewBrowserSession *iehta https://www.domainname.com/ OK,6636575977794f15be1fd6bbdabc5642
setTimeout 100000 OK
setContext TC4277 OK
isTextPresent 10560452 OK,false
isElementPresent //td[@class='pageTitle'] OK,false
isElementPresent link=Suppliers OK,false
isElementPresent link=Home OK,false
isElementPresent link=Suppliers OK,false
isTextPresent Login OK,true
isElementPresent xpath=(//input[@name='j_username'])[1] OK,false
open /aems/login.do OK
waitForPageToLoad 100000 OK
isTextPresent Home OK,false
isTextPresent Login OK,true
isElementPresent xpath=(//input[@name='j_username'])[1] OK,true
isTextPresent Home OK,false
waitForCondition selenium.isElementPresent(“xpath=(//input[@name='j_username'])[1]“) 100000 OK
type xpath=(//input[@name='j_username'])[1] xxx OK
type xpath=(//input[@name='j_password'])[1] yyy OK
click xpath=(//input[@type='submit'])[1] OK
waitForPageToLoad 100000 OK
click link=Suppliers OK
waitForPageToLoad 100000 OK
isElementPresent link=Upload History OK,true
click link=Upload History OK
waitForPageToLoad 100000 OK
isElementPresent //table/tbody/tr[td/a[contains(text(),'10560452')]][1]/td/a[contains(text(),'View')] OK,true
click //table/tbody/tr[td/a[contains(text(),'10560452')]][1]/td/a[contains(text(),'View')] OK
waitForPageToLoad 100000 OK
isElementPresent link=View Report OK,true
isVisible //div[@id='statusReportLink'] OK,true

Framework concept is based on page services so your page and related actions will be reusable from any test case. Thus test case becomes highly maintainable and utilize reusable test asset with proper modularity and semantic structure.

In case of sequential execution it will take advantage of sharing browser sessions between multiple test cases. No special coding or design required to run test in parallel, you just need to set parallel attribute’s appropriate value in configuration file (eg. false, Test, methods, classes) and framework will take care for providing thread safe browser sessions with maximum level of sharing browser session between multiple test cases. This will result in reducing time by parallel processing as well as by some level of sharing browser session(depends on configuration). You also can configure to run parallel in different browser (eg. iexplorer, firefox) with or without selenium grid.

Here is another test case, which get executed after above one. It will found the page loaded and get continued for test steps. Thus results in less execution time.

       @Priority(value = 2)
       @Test(enabled = true, groups = {"BulkUpload", "Supplier", "Report"},
       description = "Verify that application generates in-progress status bar during report execution.")
       public void TC4278() {
              String jobid = context.getAttribute("upload.jobid.TC4278").toString();
              UploadStatusPage statusPage = new UploadStatusPage(getSTB());
              statusPage.launchPage(jobid);
              getSTB().assertElementPresent(UploadStatusPage.UPLOAD_STATUS_REPORT_LINK_LOC,
                           "'View Report' link");
              getSTB().verifyIsVisible(UploadStatusPage.UPLOAD_STATUS_REPORT_LINK_DIV_LOC,
                           "'View Report' link");
              statusPage.clickUploadSatatusReportLink();
              getSTB().verifyIsVisible (UploadStatusPage.INPROGRESS_STATUS_BAR_DIV_LOC,
                           "In-progress status bar");
       }
Selenium-Command Parameter-1 Parameter-2 Res.RC
setContext TC4278 OK
isTextPresent 10560452 OK,true
isElementPresent //td[@class='pageTitle'] OK,true
getText //td[@class='pageTitle'] OK,Supplier Upload Status
isTextPresent 10560452 OK,true
isElementPresent link=View Report OK,true
isVisible //div[@id='statusReportLink'] OK,true
click link=View Report OK
isVisible //div[@id='statusReportProgress'] OK,false

When functionality changes only the specific test page file needs to be updated: if there is any change in page/ui of web application under test you need to update just in particular page rather than each and every test case, thus result in less maintenance.

Following page class illustrate how the navigation took place by derived page object. Whenever page’s launchPage method called framework will check for existence of page in browser if it is not loaded then it will call openPage method to open page from parent/launcher page (UploadHistoryPage in our case) Framework will call openPage method only if page is not loaded and parent is loaded. If parent is not loaded framework will call parent’s launch method.

public class UploadStatusPage extends BaseTestPage<UploadHistoryPage> {

      @Override
      protected void openPage(PageLocator locator) {
            parent.viewPostUploadResults(locator.getLocator());
      }

      //method below check is supplier upload status page open and for given job?
      @Override
      public boolean isPageActive() { 

            return pageLocator != null
                  && pageLocator.getLocator() != null
                  && selenium.isElementPresent("//td[@class='pageTitle']")
                        && selenium.getText("//td[@class='pageTitle']").trim().equalsIgnoreCase(
                                    "Supplier Upload Status")
                        && selenium.isTextPresent(pageLocator.getLocator());
      }
      //overloaded method for simplicity
      public void launchPage(String fileNameOrJobID) {
            launchPage(new DefaultPageLocator(fileNameOrJobID));
      }

      @Override
      protected void initParent() {
            parent = new UploadHistoryPage(stb);
      }

//all page specific functionality goes here

}

Generated Report displays:

  • description of test case
  • browser name
  • duration
  • selenium command log
  • assertion/verification/information message Screens-shots for failure (also can configure for pass assertion/verification)

FAQ

Can I run each test without sharing browser session?

Yes, set property selenium.singletone=0

It will start new selenium session for each test. Still you can save execution time by configure to run methods in parallel

How to run test in parallel?

To run test in parallel you need to set parallel attribute appropriate value in configuration file. You can found configuration details in TestNG documentation.

Can I capture screenshot for passed assertion/verification?

Yes, set selenium.success.screenshots=1. It will automatically cupture screenshot and create link for pass messages.

VN:F [1.9.10_1130]
Rating: 10.0/10 (6 votes cast)

  

{ 12 comments }

InfoStretch Test Automation Framework

[click to continue…]

VN:F [1.9.10_1130]
Rating: 9.7/10 (28 votes cast)

  

{ 27 comments }