Five Software Testing Tips

1. Prioritize your Fixes

Your software may have more bugs than you have time for at the moment, so it’s important to prioritize your fixes, ensuring that the most important issues and the issues that could be easiest to fix are tackled first.

It is absolutely necessary to have a plan of attack, and by dealing with smaller things that only take a few minutes to repair and ensuring that the most important and most widely reported issues are dealt with, you’ll be more efficient than fixing everything at once despite priorities. Keep your team in the loop – whatever process you are using for software testing should be transparent to help ensure everyone is on the same page and that priorities are clearly drawn to improve efficiency.

2. Respond to Users

You may have a list of problems or bugs that exist in production, but perhaps your users haven’t noticed or don’t care. If users are not asking for a fix, the issue can likely be put on the back burner unless it alters the functionality of the software. Listen to your users to prioritize the issues that matter most to them. After all, they’re the ones actually using your software.

typing-300x170 Five Software Testing Tips

3. Use the Right Tools

Software testing tools exist for a reason, and there’s no reason not to use them! Find the best tools for your own software and stop relying completely on your own testing abilities – the right tool could point you in the right direction or help you to discover issues you may not have known about or wouldn’t find otherwise. Most importantly, tools often provide metrics to prove what you may think you know, or can offer time saving techniques to allow you to get on with what’s important.

4. Share Your Results

You may want to keep your test results to yourself until you’re finished testing and have an exhaustive list of everything that needs to be fixed; however, if you share your issues as you find them, it is more likely that a fix will be found with more ease.

5. Learn & Improve Your Skills

 It is essential to improve not only your skills, but your testing processes and testing workflow, to ensure efficiency in software testing. Don’t keep testing the same way you’ve always done it – explore new tools, engage with your users, network with other testers, and solicit feedback from your employees and co-workers. It’s important to always be learning and improving your skills in order to up your software testing game and ensure that you strive for personal excellence, resulting in thoroughly tested software.

Testlink Implementation for Black Box Testing

  1. Create Test Project
  2. Assign Users to Test Project
  3. Create Requirement Specification
    1. Create Requirement Specification Operations
    2. Create Requirement Operations
    3. Requirement Overview
  4. Create Test Specification
    1. Create Test Suite
    2. Create Test Case Operations
    3. Automatically generate Test Cases from Requirement Operations
  5. Create Test Plan
  6. Create Build / Releases (Set mile stones)
  7. Assign Test cases to Test Plan
  8. Assign Test Cases for Test Execution
  9. Execute Test Cases and log defects
  10. Add Test Cases in between of Execution (if required)
  11. Generate Test Reports and metrics
    1. Test Report
    2. Failed Test Cases

1. Create Test Project

Users with Manager or Admin role can create Test Projects.

To create a new Test Project, click on Project link -> Test Project Management and click the Create button.

create-test-project Testlink Implementation for Black Box Testing

Enter your project details and click the Create button.

Click Project link and in the Test Project drop down at the top right select your project.

test-project-dropdown Testlink Implementation for Black Box Testing

2. Assign Users to Test Project

If a project is not created as Public, then we have to assign users to project and specify their roles. Once again, only users with Admin or Manager role can perform this action.

Use the following procedure to assign users to the new Test Project.

  • Create a Project without Public Rights.
  • Click the User Management link at the top right of the page.
  • Click Assign Test Project Roles.
  • Select your project from the Test Project drop down and click the Change button.select-project Testlink Implementation for Black Box Testing
  • Assign users appropriate rights and click the Update button when done.

3. Create Requirement Specification

3.1 . Create Requirement Specification Operations

Use the following procedure to create your Requirement Specification in TestLink.

  • Go to Project -> Requirement Specification.
  • Click the Create button.
  • Create your section requirements, user requirements and system requirements as necessary.

create-requirements Testlink Implementation for Black Box Testing

3.2 . Create Requirement Operations

Once Requirement Specification Operations are created, we can create Requirement Operations by selecting particular Requirement Specification Operations and clicking the Create button under the desired Requirement Operations.

User can create the following types of Requirement Operations:

  • Informational
  • Feature
  • Use Cases
  • User interface
  • Non Functional
  • Constraint
  • System Function

create-requirement-operations Testlink Implementation for Black Box Testing

Once all requirements are created, their status can be assigned to the following options:

  • Draft
  • Review
  • Rework
  • Finish
  • Implemented
  • Valid
  • Non testable
  • Obsolete

requirement-operation-status Testlink Implementation for Black Box Testing

The user can also enter the number of test cases required to get 100 percent test coverage for each Requirement Operation.

test-cases-needed Testlink Implementation for Black Box Testing

Once the requirements are frozen you can freeze the current version by clicking on Freeze this version.

freeze-version Testlink Implementation for Black Box Testing

When changes are required, you can create a new version of your requirements by clicking on the Create a new revision button.

create-new-revision Testlink Implementation for Black Box Testing

3.3. Requirement Overview

Users can generate a Requirement Specification overview to check the coverage of requirements and their coverage in test cases.

To access this overview, go to Project -> Requirement Overview.

requirement-overview Testlink Implementation for Black Box Testing

4. Create Test Specification

4.1 Create Test Suite

Use the following procedure to create your test suite.

  • Go to Project Link -> Test Specification and select your project.select-project1 Testlink Implementation for Black Box Testing
  • Click the Create button.create-test-suite Testlink Implementation for Black Box Testing
  • Enter mandatory details and click the Create Test Suite button.

4.2 Create Test Case Operations

Click the Create button under the Test Case Operations heading.

test-case-operations Testlink Implementation for Black Box Testing

Alternately, Test Cases can also be generated from Requirement Operations. Below are the steps to do that.

  • Navigate to Project -> Requirement Specifications.
  • Select Requirement Specification Operation.

requirement-specification-operation Testlink Implementation for Black Box Testing

4.2.1 Automatically generate Test Cases from Requirement Operations

Use the following procedure to automatically generate Test Cases from Requirement Operations.

  • Click the Create Test Cases button under the Requirement Operations heading.create-test-cases Testlink Implementation for Black Box Testing
  • Select Requirement -> Enter number of Test Cases and click the Create Test Cases button.

test-cases-requirements Testlink Implementation for Black Box Testing

This automatically generates a Test Suite with name of the Requirement Specification Operation and test cases with the name of Requirement Operation auto-incrementing by one for each required test case.

All automatically generated test cases need to be refined by editing the summary, preconditions and adding test steps. All generated test cases are automatically linked with their requirements.

generated-test-cases Testlink Implementation for Black Box Testing

5. Create Test Plan

Once Requirement and Test Cases are created we need to create a Test Plan to cover them.

Use the following procedure to create a Test Plan.

  • Navigate to Project -> Test Plan Management and click the Create button.create-test-plan Testlink Implementation for Black Box Testing
  • Enter mandatory details and click the Create button

test-plan-creation Testlink Implementation for Black Box Testing

If all goes well, your test plan should appear as follows.

test-plan Testlink Implementation for Black Box Testing

6. Create Build / Releases

Use the following procedure to create a build or release.

  • Navigate to Build / Releases and click the Create button.build-management Testlink Implementation for Black Box Testing
  • Enter Title , Description, Release Date and Click Create Button

create-build Testlink Implementation for Black Box Testing

The new Build should appear as follows.

new-build Testlink Implementation for Black Box Testing

7. Assign Test Cases to Test Plan

Next we need to assign our test cases to the test plan.

  • Navigate to your Project and select Add /Remove Test Cases.
  • Select the Test Suite under your Project.select-test-suite Testlink Implementation for Black Box Testing
  • Click on the check/uncheck all test cases for adding button to select all test cases.select-all Testlink Implementation for Black Box Testing
  • Click on the Add Selected button. All Test Cases get highlighted in yellow .

add-selected Testlink Implementation for Black Box Testing

8. Assign Test Cases for Test Execution

Now we need to assign test cases for test execution.

  • Navigate to your project and select Assign Test Case Execution.
  • Select the desired Test Suite.
  • Select Check/Uncheck All Test Cases and click the Do button to select all test cases.

select-all-test-cases Testlink Implementation for Black Box Testing

Test cases can be assigned in bulk or individually

For bulk user assignment, follow these steps.

  • Select the tester’s name and click the Do button. The tester’s name will appear in the Assign drop down to the right of each page.test-case_assignment Testlink Implementation for Black Box Testing
  • Click the Save button.

9. Execute Test Cases and log Defects

Now your testers can login with their credentials and start test execution of their assigned test cases using the following procedure:

  • Find the desired project and click Execute Tests.
  • Select the desired test cases, and click Execute.

The results will return one of the following:

  • Not Run
  • Passed
  • Failed
  • Blocked

test-case-execution Testlink Implementation for Black Box Testing

Depending on the results, select the appropriate radio button and click the Save execution button.

passed-test Testlink Implementation for Black Box Testing

failed-test Testlink Implementation for Black Box Testing

Link the defect with the failed test case and click Access to Bug Tracking System (Redmine).

bug-tracking Testlink Implementation for Black Box Testing

Log the defect in your bug tracking system, in this case Redmine. And click Link Existent Issue under Bug Management in Testlink.

bug-management Testlink Implementation for Black Box Testing

The Add bug report window will open.

Enter the Bug id and click the Add Bug button.

add-bug-report Testlink Implementation for Black Box Testing

A summary of the bug will now load with the failed test case.

Repeat as necessary.

10. Adding New Test Cases in Between Test Execution

If new test case needs to be added in between of test execution, below are the steps for same

  • Navigate to your project and select Test Specification.
  • Select the desired requirement operation.requirement-operation Testlink Implementation for Black Box Testing
  • Under the Test Case Operations heading, click the Create button.create-test-case-operation Testlink Implementation for Black Box Testing
  • Enter the mandatory test case details.
  • Navigate to Project -> Requirement Specification -> Assign Requirements.requirement-specification Testlink Implementation for Black Box Testing
  • Select the newly added test case.
  • Select Available requirements and click the Assign button to assign requirements to the test case.available-requirements Testlink Implementation for Black Box Testing
  • Navigate to the project and click Add / Remove Test cases.
  • Select the newly added test case and click the Add/Remove selected button.add-remove-test-cases Testlink Implementation for Black Box Testing
  • Navigate to the project and select Assign Test Case Execution.
  • Select newly added test case and add choose tester name from the Assigned to drop down and click the Save button.test-case-assignment Testlink Implementation for Black Box Testing

Now the tester can login with his or her normal credentials and execute the newly added test case in existing test plan.

11 .Generate Test Reports

11.1 Test Report

The test report shows the Pass/Fail status of test cases. Once execution is completed, users can generate test reports and metrics for each Test Plan.

To generate a test report,

  • Click the Test Report link at the top of the page
  • Set the Report format to HTML, or whatever other format you want.
  • Select the appropriate test plan from Test plan drop down.reports-metrics Testlink Implementation for Black Box Testing
  • Select Test Report.select-test-report Testlink Implementation for Black Box Testing
  • Select the content that you want to include in the report.test-report-content Testlink Implementation for Black Box Testing
  • Select the test project or test suite for which the test report needs to be generated.
  • Click Print button and then save as PDF.

report Testlink Implementation for Black Box Testing

11.2 Failed Test Cases

Use the following procedure to generate a report on failed test cases.

  • Select HTML as your Report format .
  • Select the desired test plan from the Test Plan drop down.
  • Click the Failed Test Cases link.failed-test-cases-settings Testlink Implementation for Black Box Testing
  • Click the Print button and save the report in PDF format.

failed-test-cases-report Testlink Implementation for Black Box Testing

Selenium WebDriver with Internet Explorer and Google Chrome

Selenium WebDriver works very well with Mozilla Firefox because it has a built in driver server. But the same is not true for Internet Explorer and Google Chrome.

If you ever get the “the path to the driver executable must be set by the webdriver.ie.driver system property” error or its similarly worded Chrome equivalent, it means that you need to install the driver servers on your browser. The driver server manages the calls between the browsers and the Selenium wire protocol.

Luckily, the driver servers are easy to get.

The InternetExplorerDriver is a standalone server which implements WebDriver’s wire protocol. This driver has been tested with IE 6, 7, 8 and 9 on appropriate combinations of XP, Vista and Windows 7. You can download it from the following URL-

https://code.google.com/p/selenium/downloads/list

The downloaded file is an exe file, but you don’t install it like other exe files. Instead, you add the following lines of code above your Internet ExplorerDriver object:

[code]System.setProperty("webdriver.ie.driver","ieDriverpath");
driver=new InternetExplorerDriver();

// ieDriverPath is the path of your downloaded IEDriverServer file[/code]

Similarly,  Google Chrome doesn’t have a built-in server so you will need a Chrome driver server for communicating your Selenium code to the browser. You can download the Chrome driver server from the above Google Code URL. Then add the following code to your existing Selenium code:

[code]System.setProperty("webdriver.chrome.driver","chromeDriverPath");

driver=new ChromeDriver();

// chromeDriverPath is the path of your downloaded chromeDriverServer file[/code]

If you have any further troubles running your Selenium tests on Chrome, it may be worthwhile checking  the chromedriver release notes.

Let me know in the comments if you have any questions.

Aggregating Correlated Sub-Queries in SQL Server 2008

While working on a query I was trying to calculate an aggregate function such as SUM() on a correlated subquery and received the following error:

Msg 130, Level 15, State 1, Line 24
Cannot perform an aggregate function on an
expression containing an aggregate or a subquery.

Here are a couple of solutions you can use to get around this error.

Let’s start by looking at a typical example of summing up a correlated SUM(). Suppose you have written the following SELECT:

[code lang=”sql”]select Company.Name
,Company.Region
, (select sum(Amount) from Orders where Orders.CompanyID = Company.CompanyID) as Total
from Company[/code]

Notice that we have used a correlated sub-query to return the total Order Amount per Company. Working from that, let’s say that you instead would like to the return the total Order Amount by Region. Typically, you would remove Company from the SELECT list, add GROUP BY Region to the end, and wrap what you’d like to total in a SUM() aggregate function:

[code lang=”sql”]select Company.Region
,sum(select sum(Amount) from Orders where Orders.CompanyID = Company.CompanyID) as Total
from Company
group by Company.Region[/code]

Unfortunately, that is not a valid SQL statement, since you are trying to directly SUM() a correlated sub-query (which also happens to have a SUM() in it already). This is not allowed in SQL Server; if you try to execute that, you’ll be greeted with the error mentioned above.

There are two ways to fix this

Option 1: Use a derived table

Perhaps the easiest solution is to simply wrap your original SELECT in a derived table, and then select from that derived table and do the grouping in the outer select:

[code lang=”sql”]select Region
,sum(Total) as Total
from
(select Company.Name, Company.Region, (select sum(Amount) from Orders
where Orders.CompanyID = Company.CompanyID) as Total from Company
) x
group by Region[/code]

This is logically equivalent to what we tried to do earlier, except it is now a valid SQL statement and it will return the correct results without an error. This is a very quick and easy way to solve this situation in general, though it is not always the optimal solution in terms of performance and readability.

Option 2: Rewrite your SELECT without a Correlated Subquery

Often the best solution is to rewrite your SELECT without using a correlated sub-query at all. In our example, we could write the original as:

[code lang=”sql”]select Company.Name
,Company.Region
,sum(Orders.Amount) as Total
from Company
left Join Orders on Orders.CompanyID = Company.CompanyID
group by Company.Name
,Company.Region[/code]

Once the SELECT is re-written, we can now easily adjust that to return only totals by Region simply by removing Company.Name from the SELECT and GROUP BY clauses:

[code lang=”sql”]select Company.Region, sum(Orders.Amount) as Total
from Company
left outer Orders on Orders.CompanyID = Company.CompanyID
group by Company.Region[/code]

This is usually a good way to solve the issue because the end result is very efficient and well-structured, so it is easier to understand and maintain.

Data Sovereignty in Canada

Summary

Most companies operating in Canada can store data wherever they want as long as they take measures to secure personal data.

Service providers working with public bodies in BC and Nova Scotia have stricter data sovereignty requirements including storing data in Canada.

Concerns about accessing data through the PATRIOT Act are misplaced because there are broader mechanisms in place for requesting and sharing data between governments and law enforcement agencies that predate the PATRIOT Act.

The PATRIOT Act

The PATRIOT Act was enacted in 2001 and it broadly extended US law enforcement’s powers to access data.

Companies with a presence in the US are subject to the PATRIOT Act regardless of where the data is physically located or where they are headquartered.

Canada offers no protections against the PATRIOT Act and only British Columbia and Nova Scotia have enacted any form of protection against the PATRIOT Act.

Furthermore, Canada, like most countries, has enacted legislation that grants similar powers to Canadian law enforcement agencies and, like most western countries, has agreements in place to share that information with foreign allies.

So, even if your company only operates in Canada and your data resides entirely in Canada, US law enforcement agencies can ask their Canadian counterparts for the data and the Canadian authorities will likely comply.

The main lesson is that if there is reasonable suspicion of criminal wrongdoing, then it doesn’t matter where the data is stored. For typical, non-criminal businesses, locating data in Canada with a Canadian hosting company offers very little additional protection.

Canada’s Patriot Act: PIPEDA

The Personal Information Protection and Electronic Documents Act (PIPEDA) governs how data on Canadians is collected, used and disclosed.

The main obligation for Canadian companies set out by PIPEDA is the requirement that “personal information shall be protected by security safeguards appropriate to the sensitivity of the information.”

You can store data wherever you want, just make sure anything sensitive is encrypted and password protected.

One of the main exceptions to PIPEDA’s protections is law enforcement and national security. That exception extends to sharing data with foreign bodies.

The Office of the Privacy Commissioner of Canada made this clear in a submission to the Office of the Information and Privacy Commissioner for British Columbia titled Transferring Personal Information about Canadians Across Borders–Implications of the USA PATRIOT Act.

“Canadian law often permits government agencies to share personal information that is held in Canada (by government or the private sector) with foreign governments and organizations, even without the consent of the individual to whom the information relates.”

Canada has signed a number of Mutual Legal Assistance Treaties with countries like the US and the UK that provide mechanisms for requesting evidence.

The Department of Justice then needs to apply for a search warrant before obtaining the information and then sharing it with the body that made the request.

British Columbia and Nova Scotia have enacted laws that govern records held by public bodies that apply to service providers working with public bodies. Both laws require that data be stored in Canada.

Freedom of Information and Protection of Privacy Act (BC)

The Freedom of Information and Protection of Privacy Act (FOIPPA) regulates access to records held by public bodies and privacy standards for such records in the province of British Columbia (BC).

Many of the privacy-related sections of the act apply to “officers of the Legislature, their employees and, in relation to their service providers, the employees and associates of those service providers, as if the officers and their offices were public bodies.”

That means that if you provide services for a public body in BC, then FOIPPA may apply to you.

Sections that apply include the data sovereignty provisions of FOIPPA which require that data collected by public bodies in BC be stored in Canada.

In addition to storing the data in Canada, organizations subject to FOIPPA are required to report foreign demand for disclosure to the minister responsible for FOIPPA.

This means that companies subject to the Patriot Act would be compelled to give requested data to US authorities and report the transaction to BC authorities. In practice, US authorities would likely ask Canadian authorities (who are exempted from notification) to share data thus circumventing any FOIPPA protections and responsibilities.

Most of the other applicable sections are related to storing data securely and unauthorized disclosure/access.

The following is the complete list of sections that apply to service providers as listed in the act:

  • Section 30: Protection of personal information.
  • Section 30.1: Storage and access must be in Canada.
  • Section 30.2: Obligation to report foreign demand for disclosure.
  • Section 30.3: Whistle-blower protection.
  • Section 30.4: Unauthorized disclosure prohibited.
  • Section 30.5: Notification of unauthorized disclosure.
  • Section 33: Disclosure of personal information.
  • Section 33.1: Disclosure inside or outside Canada.
  • Section 33.2 Disclosure inside Canada only.
  • Section 74.1: Privacy protection offences.

Personal Information International Disclosure Protection Act (NS)

The Personal Information International Protection Act (PIIDPA) applies to personal information collected by public bodies in Nova Scotia.

The act also applies to service providers defined as “an individual or a company that is retained under a contract to perform services for a public body, and in performing those services, uses, discloses, manages, stores or accesses personal information in the custody or under the control of that public body.”

Similar to the BC law, PIIDPA requires data covered under the act be stored in Canada. It also requires that foreign requests for disclosure be reported to the Minister responsible for the act, but specifically exempts foreign law enforcement agencies that request information through federal or provincial agreements.

In addition, it specifically prohibits storing PIIDPA data in portable devices while travelling unless given specific permission.

Conclusion

At the moment, there are very few data sovereignty requirements that apply to Canadian companies. The most common ones are satisfied by basic security practices that you should already be doing.

Keeping your data in Canada over PATRIOT Act concerns is also unnecessary. Most Western countries already had mechanisms in place where Canadian authorities would provide data that resides in Canada. The PATRIOT Act mostly only asserted the US’s right to unilaterally request data from companies with a presence in the US where they already had the bilateral right to do so from companies in Canada.

The only way that you can guarantee that you are made aware of those requests is by running your own data center, when you receive the subpoena for the data, or if you are working with data belonging to public bodies in BC and Nova Scotia, where provincial data sovereignty laws apply.

As with any post on legal topics here, this is an overview of the laws and does not replace proper legal advice in any way.

 

Running AutoIT Executable in Selenium WebDriver

Web applications do not always confine themselves to working entirely on the web. Sometimes they need to interact with the desktop to do things like upload files.

Automating these sorts of workflows are tricky in Selenium. Selenium is confined to automating browsers, so desktop windows are out of scope.

If you are looking to automate workflows that go from browser to desktop and back in Selenium, then a little AutoIT is in order.

AutoIt is a tool for desktop automation. Using AutoIT, you can write scripts for automating desktop-based application and convert them in to an executable file.

The first step is to make automate that desktop-based window in AutoIT and make an executable file. The exact substance of the file depends on your project, but it is a pretty straight-forward task in AutoIT.

The second step is to invoke that executable at run time. Use the following method to invoke the executable from Selenium.

import java.io.IOException;
 import java.lang.Runtime;
 //Method to execute an exe file
 public void executeScript(String scriptPath) throws IOException
 {
 //scriptPath is the path of the executable
 Runtime.getRuntime().exec(scriptPath);
 }

As soon as you invoke this method, all the recorded steps in the executable will be executed and the desktop based window will be automated.

Some disadvantages of using the AutoIT executable are following-

  1. These scripts are window resolution dependent, so it may fail sometime.
  2. In case of uploading a file, if the uploading is taking more time due to some server/internet error, the scripts may not be able to fulfill the purpose.

To solve the first problem, you can use object information of the controls and window so you won’t have to depend on screen resolution.

To solve the second problem, you can specify the timeout period using the winwaitactive function which will give you definite results regardless of server or Internet errors.

Using predefined or user-defined AutoIT functions will make your Selenium scripts more consistent.

The post Running AutoIT Executable in Selenium WebDriver appeared first on OptimusQA.

Running AutoIT Executable in Selenium WebDriver

Web applications do not always confine themselves to working entirely on the web. Sometimes they need to interact with the desktop to do things like upload files.

Automating these sorts of workflows are tricky in Selenium. Selenium is confined to automating browsers, so desktop windows are out of scope.

If you are looking to automate workflows that go from browser to desktop and back in Selenium, then a little AutoIT is in order.

AutoIt is a tool for desktop automation. Using AutoIT, you can write scripts for automating desktop-based application and convert them in to an executable file.

The first step is to make automate that desktop-based window in AutoIT and make an executable file. The exact substance of the file depends on your project, but it is a pretty straight-forward task in AutoIT.

The second step is to invoke that executable at run time. Use the following method to invoke the executable from Selenium.

[code lang=”java”]import java.io.IOException;
import java.lang.Runtime;
//Method to execute an exe file
public void executeScript(String scriptPath) throws IOException
{
//scriptPath is the path of the executable
Runtime.getRuntime().exec(scriptPath);
}[/code]

As soon as you invoke this method, all the recorded steps in the executable will be executed and the desktop based window will be automated.

Some disadvantages of using the AutoIT executable are following-

  1. These scripts are window resolution dependent, so it may fail sometime.
  2. In case of uploading a file, if the uploading is taking more time due to some server/internet error, the scripts may not be able to fulfill the purpose.

To solve the first problem, you can use object information of the controls and window so you won’t have to depend on screen resolution.

To solve the second problem, you can specify the timeout period using the winwaitactive function which will give you definite results regardless of server or Internet errors.

Using predefined or user-defined AutoIT functions will make your Selenium scripts more consistent.

GROUP BY vs DISTINCT in SQL Server

Yesterday, I was travelling in the metro where I overheard two college students puzzling over the difference between GROUP BY and DISTINCT.

GROUP BY and DISTINCT cause a lot of confusion and I couldn’t help myself so I jumped into their conversation and explained the differences.

Their problem was understanding where to use GROUP BY and where to use DISTINCT when both return same results in most scenarios when no aggregates are used, and which one had better performance.

GROUP BY and DISTINCT both generate the same query execution plan when no aggregates are used, so there is no appreciable difference in performance in this situation.

GROUP BY becomes important when aggregates are used. DISTINCT is just for filtering out duplicate records from query result sets.

Ideally, when aggregates are not used in a query, then one should use DISTINCT to enhance readability. But when aggregates are used GROUP BY performs much better.

Here are some examples:

DISTINCT

SELECT DISTINCT Name, RollNo
 FROM Student

GROUP BY

SELECT Name, RollNo
 FROM Student
 GROUP BY Name, RollNo

GROUP BY with Aggregate Function

SELECT Name, RollNo, Sum(Marks) TotalMarks
 FROM Student
 GROUP BY Name, RollNo

The post GROUP BY vs DISTINCT in SQL Server appeared first on OptimusBI.

Keyword-Driven Alert Handling in Selenium

Alerts and other pop ups cause your well-crafted Selenium tests to grind to a stop unless you handle them properly. The reason for this is that control moves to the alert instead of continuing with the open browser.

In most cases, you just need just need to automate accepting or rejecting the alert buttons which is relatively straightforward.

If you are using a keyword-driven framework, you need to do the following to handle alerts in Selenium.

  1. Find the ID of the button which opens the alert window. You can do this easily with Firebug in Firefox.
  2. Pass this ID. We have an Excel-based framework that we use where we can specify keywords and objects. The ID of the button would be the object in our framework.
  3. Invoke acceptAlertButtonByID or dismissAlertButtonByID keywords by specifying the exact name of the keyword in Excel.
The following Java code contains the keywords for accepting or dismissing buttons.
//To click the button by which an alert is generated and then accept the alert using id
    public  String acceptAlertButtonByID(String object,String data){
           APP_LOGS.debug("Clicking on button and acccepting the alert");
           try{
               driver.findElement(By.id(object)).click();
               Alert alert = driver.switchTo().alert();
              alert.accept();
               }catch(Exception e){
                    return Constants.KEYWORD_FAIL+" Not able to accept alert";
              }
            return Constants.KEYWORD_PASS;
    }

//To click the button by which an alert is generated and then dismiss the alert using id
    public  String dismissAlertButtonByID(String object,String data){
           APP_LOGS.debug("Clicking on button and dismissing the alert");
           try{
               driver.findElement(By.id(object)).click();
               Alert alert = driver.switchTo().alert();
               alert.dismiss();
               }catch(Exception e){
                    return Constants.KEYWORD_FAIL+" Not able to dismiss alert";
              }
            return Constants.KEYWORD_PASS;
    }

The post Keyword-Driven Alert Handling in Selenium appeared first on OptimusQA.

Keyword-Driven Alert Handling in Selenium

Alerts and other pop ups cause your well-crafted Selenium tests to grind to a stop unless you handle them properly. The reason for this is that control moves to the alert instead of continuing with the open browser.

In most cases, you just need just need to automate accepting or rejecting the alert buttons which is relatively straightforward.

If you are using a keyword-driven framework, you need to do the following to handle alerts in Selenium.

  1. Find the ID of the button which opens the alert window. You can do this easily with Firebug in Firefox.
  2. Pass this ID. We have an Excel-based framework that we use where we can specify keywords and objects. The ID of the button would be the object in our framework.
  3. Invoke acceptAlertButtonByID or dismissAlertButtonByID keywords by specifying the exact name of the keyword in Excel.
The following Java code contains the keywords for accepting or dismissing buttons.
[code lang="java"]//To click the button by which an alert is generated and then accept the alert using id
    public  String acceptAlertButtonByID(String object,String data){
           APP_LOGS.debug("Clicking on button and acccepting the alert");
           try{
               driver.findElement(By.id(object)).click();
               Alert alert = driver.switchTo().alert();
              alert.accept();
               }catch(Exception e){
                    return Constants.KEYWORD_FAIL+" Not able to accept alert";
              }
            return Constants.KEYWORD_PASS;
    }

//To click the button by which an alert is generated and then dismiss the alert using id
    public  String dismissAlertButtonByID(String object,String data){
           APP_LOGS.debug("Clicking on button and dismissing the alert");
           try{
               driver.findElement(By.id(object)).click();
               Alert alert = driver.switchTo().alert();
               alert.dismiss();
               }catch(Exception e){
                    return Constants.KEYWORD_FAIL+" Not able to dismiss alert";
              }
            return Constants.KEYWORD_PASS;
    }[/code]