Monday, September 19, 2011

Challenges faced in ext js

Hi,
I.m working on ext js application, whose speciality is,all the elements of the page are dynamic.This indicates that its not automation friendly.
I'll post some of the locators which i used to locate elements.


Selecting from drop down
There is a select list, which contains a text box and down arrow image button, clicking on button image, opens a drop down which contains element with dynamic id's.
Dynamic elements are : drop down elements (div's) , and image button.
 Clue is, input box has an id.

This can be located as.

//input[@id='abc']/following-sibling::img

this clicks on image .now we need to select the dropdown list element , which also has dynamic id.
So,i used text function as,

//div[text()='CPA']

which clicks on cpa in the dropdown list.

Locating elements with same name ,based on their position using css

I hadto locate 3 elements with same id.(Accounts). All had same name, no other unique identifier.

So,i could locate them using,

css=div#salestabs  td[class*=Accounts ]
css=div#salestabs  td[class*=Accounts ]  div:nth(1)
css=div#salestabs  td[class*=Accounts ]  div:nth(2)


Css will locate element based on their parent element.The above css looks so simple, but the dom is so complex.

div has class name x-combo-list-inner,under that


<div class="x-combo-list-item">YYYY-Month</div>
<div class="x-combo-list-item  x-combo-selected">YYYY-MM</div>
<div class="x-combo-list-item  x-combo-selected">MM-YYYY</div>

and then div closes(</div>)

Another div having same class name and same list of combo items as mentioned above. is located below the above div.

 <div class='x-combo-list-inne'>
<div class="x-combo-list-item">YYYY-Month</div>
<div class="x-combo-list-item  x-combo-selected">YYYY-MM</div>
<div class="x-combo-list-item  x-combo-selected">MM-YYYY</div>
 </div>

this can be located as

css=div[class*='x-combo-list-inner'] div:nth(2)---locates  3rd element of 1st div.

css=div[class*='x-combo-list-inner'] div:nth(5)--locates 3rd element of 2nd div.


Post will be continued as n wen i find more challenges.....

















Friday, February 4, 2011

Suite creation in Junit4

Suite creation in Junit4

First Test


package com;


import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class FirstOne {
   
    private static SeleniumServer seleniumServer;
    private static Selenium selenium = new DefaultSelenium( "localhost",4444, "*chrome","http://www.google.com");
   
    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        seleniumServer = new SeleniumServer();
        seleniumServer.start();
        selenium.start();
    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception {
          selenium.stop();
          seleniumServer.stop();
    }

    @Test
    public void Testing() throws Exception{
        selenium.open("/");
        selenium.waitForPageToLoad("6000");
        selenium.type("q", "search");
        selenium.click("btnG");
}

}


Second Test



package com;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class SecondOne {

private static SeleniumServer seleniumServer;
private static Selenium selenium = new DefaultSelenium( "localhost",4444, "*chrome","http://www.google.com");

@BeforeClass
public static void setUpBeforeClass() throws Exception {
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
selenium.stop();
seleniumServer.stop();
}

@Test
public void Testing() throws Exception{
selenium.open("/");
selenium.waitForPageToLoad("6000");
selenium.type("q", "selenium");
selenium.click("btnG");
}
}


Suite Class 


package com;



import org.junit.runner.RunWith;

import org.junit.runners.Suite;



@RunWith(Suite.class)

@Suite.SuiteClasses({FirstOne.class, SecondOne.class})

public class TestSuite {

//nothing

}

Saturday, January 29, 2011

Program to login into a webpage using selenium Webdriver

Login into a page with username text box having id as loginid,password id as password and button id as button.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Login {
     public static void main(String[] args) throws Exception {
               WebDriver driver = new FirefoxDriver();
            driver.get("http://");
            WebElement id = driver.findElement(By.id("loginID"));
            WebElement pass = driver.findElement(By.id("password"));
            WebElement button = driver.findElement(By.id("Button"));
           
            id.sendKeys("Cheese");
            pass.sendKeys("password");
            button.click();
           
           
     }
           
}

Thursday, January 13, 2011

AutoIT Script Generator-AU3Recorder

To write autoit scipt,we need not learn the autoit scripting language.Instead ,we can download SciTE4AutoIt3from http://www.autoitscript.com/autoit3/scite/downloads.shtml and install.Of course you need to have downloaded AutoIt from http://www.autoitscript.com/autoit3/downloads.shtml  and installed, before installing SciTE.
  
What can AU3Record do for you:
  1. It will record Mouseclicks and Keyboardstrokes for you and translate those into AutoIt3 commands.
  2. There is a AU3Record included which will store the recorded information into the currently edit file.

    After installing ,goto start->programs->autoitv3->Scite Script Editor.

    A window opens->go to tools and select AU3Recorder.
        Also you can Start AU3Record by  hitting Alt+F6:

Optionally Select the program you want to run before starting to recording and click on REC.
Now do all pointing, clicking and typing and when finished click on
Something like this will be inserted into you active script:



 Save the file by clicking save as-> new.au3 . and then double click on saved file to execute the recorded action.

Solution to possible problem: When you click new file,it doesn't show au3recorder under tools until you save the file as autoITscript

Links to learn SoapUI

Important Links to learn SoapUI

Basics

http://java.dzone.com/articles/functional-web-services-1?page=0,0

Groovy Programming


http://java.dzone.com/articles/draft-functional-web-services--0

Integrating soapUI with CI

http://java.dzone.com/articles/functional-web-services-testin-1

Friday, January 7, 2011

Test Link installation on windows

Hi,
Test link is a Test Management Tool and is based on PHP, MySQL, and includes several other open source tools and it also supports interface to various Bug tracking systems.

The tool enables quality assurance teams to create and manage their test cases as well as organize them into test plans. These test plans allow team members to execute test cases and track test results dynamically, generate reports, trace software requirements, prioritize and assign.

 
Test Link is open source which is used for test management.So,I thought let me give a try.Test link is supported by hudson,that is also another reason to start working on Test link.

Follow these steps to install,

  1. Download WAMPSERVER exe from http://download.cnet.com/WampServer/3000-18506_4-10797035.html?tag=mncol;1
  2. Double click on wampserver exe to install and place it in some folder. for ex: D:\wamp\
  3. Download Test Link from http://sourceforge.net/projects/testlink/files/TestLink%201.9/TestLink%201.9.0/testlink-1.9.0.zip/download 
  4. Extract the downloaded testlink in www folder of wamp. D:\wamp\www
  5. In the notification area on windows,click on wampserver and select start all services.
  6. Now go to http://localhost:80/testlink/
  7. Click on click here for new installation.
  8. Give database name as mysql and host as localhost.
  9. Give the meaningful database name as testlink.
  10. Provide admin and admin as testlink's username and password.
  11. Click on setup test Link.
  12. Now you are ready to use the testLink. 
  13. Use the user name and password as admin and admin to login as user.
  14. If it doesn't login,then give this statement. mysql -u root -proot testlink < D:\wamp\www\testlink\install\sql\mysql\testlink_create_tables.sql . where testlink is db name and mysql username,password is root and root.
  15. Now the installation is over.You can login as admin and create testcases and test suite.



Benefits of Testlink:
This is open source (free to use) test management tool.
Easy to maintain for multiple project( don’t have to write test case again and again)
Centralized Repository for all Test cases
Centralized Repository for Results
Bug Tracking tool can also be integrated( Jira, Bugzilla etc.)
Requirement mapping can be done
Multiple Reports and charts can be viewed( Build wise Report, Multiple build execution report, Requirement coverage report, Total bugs logged for the application etc).Report can be viewed on email
(src: http://testlinktool.yolasite.com)

Tuesday, January 4, 2011

Google Auto Complete Program

Here's simple program to accomplish google's autocomplete feature



package com.example.tests;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class googleAutocomplete extends SeleneseTestCase {
    public void setUp() throws Exception {
        setUp("http://www.google.co.in/", "*chrome");
    }
    public void testGoogleAutocomplete() throws Exception {
        selenium.open("/");
        selenium.type("q", "sele");
        selenium.typeKeys("q", "nium");
        selenium.click("//div[@class='gac_id']/table/tbody/tr[3]/td");
        selenium.keyPress("btnG", "\\13");
    }
}

Sunday, January 2, 2011

Code to start Selenium Server in TestNG

This is the basic structure of TestNG class

package file;

import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.SeleniumServer;

public class NewTest {
private SeleniumServer seleniumServer;
private Selenium selenium = new DefaultSelenium( "localhost",4444,
"*chrome","http://");

@Test
public void f() {
}

@BeforeTest
public void beforeTest() throws Exception {
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}

@AfterTest
public void afterTest() {
selenium.stop();
seleniumServer.stop();
}

}