Monday, November 7, 2016

Selenium IDE Panes and Shortcut keys



Selenium IDE Layout is divided into following areas: 


 MenuBar – Below are the top level menu options available in Selenium IDE.
  • File – Allows creating new test case, test suite, open existing test case, test suite, exporting tests to other formats.
    • From the File Menu, We can perform various tasks:
      • Create New Test Case.
      • Create new Test Suite.
      • Save test cases and test suites.
      • Export Test cases/test suites to various formats. E.g : Ruby/Python/java/c# with WebDriver or RC.
      • Open existing test cases and test suites.
      • Rename a test case
  • Edit – Allows editing existing test steps, and adding new commands and comments
  • Actions – Allows to record, play a test, execute command, toggle breakpoint and set entry point.
  • Options – Allows changing of settings including set the timeout value for commands,specifying the format used for saving test cases and creating log file for selenium execution
  • Help – provides documentation for selenium IDE.
Selenium IDE Layout
Understanding Panes in Selenium IDE

  •      Toolbar – Provides buttons to manage test execution including test execution and test execution.
  •      Test Case Pane – Test Case Pane shows the list of test case on the left and test steps in table or    source pane on the right. We can add/modify commands, target and value in the table for the test.
  •      Log/Reference/UI-Element/Rollup Pane – This pane helps us to view logs of execution, reference explaining the selected command. We can also set to filter logs for info, warning, error and debug in this window.

ShortCut Keys: Selenium IDE


New Test - Ctrl + N
Open a test - Ctrl + O
Save a test - Ctrl + S
Add test to test suite - Ctrl + D.
Close Selenium IDE - Ctrl + W
Undo - Ctrl + Z
Redo - Ctrl + Y
Cut - Ctrl + X
Copy - Ctrl + C
Paste - Ctrl + V
Delete - Del
Select All - Ctrl + A

Saturday, November 5, 2016

Using dependencies and priority in TestNG tests: Ordering tests execution

Suppose there are three tests in a test class which needs to be executed, we can define the tests in the class as shown below:


public class TestOrder {
@Test
public void TestA() {
System.out.println("test a");
}

@Test
public void TestB() {
System.out.println("test b");
}

@Test
public void TestC() {
System.out.println("test c");
}
}


When we execute the test class, all the three tests are executed, but order of the test is not sure. We can prioritize the test using priority.


public class TestOrder {
@Test(priority=1)
public void TestA() {
System.out.println("test a");
}

@Test(priority=2)
public void TestB() {
System.out.println("test b");
}

@Test(priority=3)
public void TestC() {
System.out.println("test c");
}
}


Since there can be many tests in a test suite, and it can be difficult to prioritize tests based on numbering tests. In such cases,we can prioritize the tests based on dependsongroup or dependsonmethod as shown below.  Using groups, we can group the tests based on functionality and scope of the tests




public class TestOrder {
@Test(groups = { "smoke" })
public void TestA() {
System.out.println("test a");
}

@Test(dependsOnMethods = { "TestD" }, groups = { "regression" })
public void TestB() {
System.out.println("test b");
}

@Test(dependsOnGroups = { "smoke" })
public void TestC() {
System.out.println("test c");
}

@Test
public void TestD() {
System.out.println("test d");
}
}

How to run multiple test suites in TestNG?

Suppose we have individual test suite for different features/modules in TestNG, we can run multiple testNG test from a master suite xml file by calling the individual tests as shown below:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="MainTestSuite">
    <suite-files>
        <suite-file path="suiteFeatureA.xml" />  
        <suite-file path="suiteFeatureB.xml" /> 
        <suite-file path="suiteFeatureC.xml" />  
        <suite-file path="suiteFeatureD.xml" />      
    </suite-files>
</suite>


This way, we can run multiple test suites from a master suite file in TestNG.