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