Wednesday, 30 April 2014

Difference Between Assert and Verify

Verify command will not stop execution of test case if verification fails. It will log an error and proceed with execution of rest of the test case. We use verify commands in Selenium IDE when we still want to proceed with execution of test case even if expected output if not matched for a test step.

For example: After clicking on Selenium IDE tab on questionselenium.com , I'll do a verification to check if it showing Table of contents with all entries. If verification failed then I could still test rest of the elements under Selenium IDE page by logging in a verification failure for test step that checks Table of contents.

Assert command will stop execution of test case if verification fails. It will log an error and will not proceed with execution of rest of the test case. We use assertions in scenarios where there is no point proceeding further if expected output is not matched.



Its pretty simple.
  • Use assertions when you want to stop execution of a test case if expected output is not matched 
  • Use verification when you still want to proceed execution of a test case if expected output is not matched.

Not able to open Web Page Selenium Driver

Method get requires the protocol as part of the URL

Change:
String baseurl = "www.google.com";
 
To:
String baseurl = "http://www.google.com";

Tuesday, 29 April 2014

Selenium Screenshot

package mypackage;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Screenshot {
  
    @Test
    public void takeScreenshot() throws InterruptedException, IOException  {
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.google.com.tr");
        driver.manage().window().maximize();
        Thread.sleep(2000);
        driver.findElement(By.id("gbqfq")).sendKeys("onurtest");
        driver.findElement(By.name("btnG")).click();
        Thread.sleep(3000);
        // take the screenshot
        File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
        // now save the screenshot to a file some place
        FileUtils.copyFile(scrFile, new File("h:\\tmp\\screenshot.png"));
        WebElement resultsLabel = driver.findElement(By.id("resultStats"));
        assertEquals(true, resultsLabel.isDisplayed());
        driver.close(); // This will not execute
    }

}






Selenium Supported Browsers

Selenium tools can run in following browsers.

•Internet Explorer
•FireFox
•Opera
•Safari
•Seamonkey


Python Programming Eclipse - PyDev plug-in for Eclipse

Go to Help → Install New Software

  1. Enter http://pydev.org/updates in the Work with:  field.
  2. After several seconds, two options should appear. Select the PyDev for Eclipse option. Do not select the "PyDev Mylyn Integration" flag




     When the installation is complete, you will be asked if you want to restart Eclipse. Select "Yes". You may see a Subclipse Usage  dialog, just uncheck the box and continue.





     Click "New..." and type Python32 for the Interpreter name. For the Interpreter executable, browse to your copy of Python (C:\Program Files\Python32\python.exe), and press Open.







    1. Go to File → New → PyDev Project to start a wizard.







      you should now see your newly created project with a "src" folder inside.








Monday, 28 April 2014

Tomcat Directory Structure

 

 

Directory Structure

Tomcat installation provides these directories:
  • bin: for Tomcat's binaries and startup scripts.
  • conf: global configuration applicable to all the webapps. The default installation provides:
    • One Policy File: catalina.policy for specifying security policy.
    • Two Properties Files: catalina.properties and logging.properties,
    • Four Configuration XML Files: server.xml (Tomcat main configuration file), web.xml (global web application deployment descriptors), context.xml (global Tomcat-specific configuration options) and tomcat-users.xml (a database of user, password and role for authentication and access control).
    The conf also contain a sub-directory for each engine, e.g., Catalina, which in turn contains a sub-sub-directory for each of its hosts, e.g., localhost. You can place the host-specific context information (similar to context.xml, but named as webapp.xml for each webapp under the host).
  • lib: Keeps the JAR-file that are available to all webapps. The default installation include servlet-api.jar (Servlet), jasper.jar (JSP) and jasper-el.jar (EL). You may also keep the JAR files of external package here, such as MySQL JDBC driver (mysql-connector-java-5.1.{xx}-bin.jar) and JSTL (jstl.jar and standard.jar).
  • logs: contains the engine logfile Catalina.{yyyy-mm-dd}.log, host logfile localhost.{yyyy-mm-dd}.log, and other application logfiles such as manger and host-manager. The access log (created by the AccessLogValve) is also kept here.
  • webapps: the default appBase - web applications base directory of the host localhost.
  • work: contains the translated servlet source files and classes of JSP/JSF. Organized in hierarchy of engine name (Catalina), host name (localhost), webapp name, followed by the Java classes package structure.
  • temp: temporary files.

Sunday, 27 April 2014

Create Maven Project

How to create a simple project using maven.

Maven is a build automation tool used primarily for Java projects. Maven addresses two aspects of building software: First, it describes how software is built, and second, it describes its dependencies. 

Maven Standard Directory should be like that






Every Maven project has what is known as a Project Object Model (POM) in a file named pom.xml. This file describes the project, configures plugins, and declares dependencies.



Source code and resources are placed under src/main. In the case of our simple Java project this will consist of a few Java classes and some properties file. In another project, this could be the document root of a web application or configuration files for an application server.



Test cases are located in src/test. Under this directory, Java classes such as JUnit or TestNG tests are placed in src/test/java



Maven dynamically downloads Java libraries and Maven plug-ins from one or more repositories such as the Maven 2 Central Repository, and stores them in a local cache


 Maven has 3 type of repository

1- Local
2- Central
3- Remote

By default maven’s local repository exist on following path :

C:/Documents and Settings/.m2/repository


Create simple Maven Project

mvn archetype:create -DgroupId=com.test -DartifactId=mytest



 if maven cant   find any dependency in local repository, starts searching in central repository using following URL: http://repo1.maven.org/maven2/


POM xml :

It describes the project's name, group, version, dependencies, and many many other things. The contents of the generated pom.xml file are shown below. 



Build lifecycle

One of Maven's standard lifecycles is the default lifecycle, which includes the following phases

 

 

 

 

 

 

 

 

 

 

 


Selenium RC Intro (Giriş)



Pre-requisites for Selenium RC:

 - Selenium IDE
 - Eclipse IDE

Selenium RC iki bölümden oluşur  (Selenium RC comes in two part)


  • Server which handles the browsers
  • Client Driver for computer language
















How it works

- First client driver establish connection to Selenium RC

- Selenium RC launch URL which you specified

- Client pass the command to Selenium RC

- RC Server interprets the command and then execute it

- After all commands executed browser will be closed

- Send results back to client side






Selenium WebDriver


Step 1 - Sisteminizde Java JDK kurulu olmalidir  (Download and install Java in your system)



Step 2 - Eclipse kurulu olmalidir (Download eclipse from here)



Step 3 - Selenium Java Client download edilmelidir (Download Selenium Java Client)



Step 4 - Jar dosyasi extract edilir (libs ve diger 2 tane jar dosyasi projeye import edilmelidir.)



Step 5 - Eclipse java projesi yaratilir. (Create java project)


Step 6 - Jar dosyalari proje ye import edilir.


Step 7 - Test class i olusturulur

package test;

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

public class TestClass {
  
    public static void main(String[] args) {
     
        //Here we initialize the firefox webdriver
        WebDriver firefoxDriver=new FirefoxDriver();
     
        //Open the url which we want in firefox
        firefoxDriver.get("Http://www.google.com");

    }
}


Step 8 - Aşağıdaki firefox ta google.com açılmalıdır.


Saturday, 26 April 2014

Add-ons to Identify Selenium Locators





1. Firebug
Firebug has become the de facto tool for web developers, as it allows developers to find elements on the page by using the find functionality.
It has a JavaScript REPL. REPL stands for Read-Eval-Print-Loop, which is an interactive shell that allows you to run JavaScript without having to create
an entire page.
Download


2. Firefinder
A very good tool for testing out XPath and CSS on the page. It will highlight all the elements on the page that match the selector to your element location.
Download

3. IE Developer Tools
This is built into IE7 and IE8, which we you launch by pressing F12. It also has a number of features that Firebug has.

4. Google Chrome Developer Tools
This, like IE, is built into the browser and will also allow you to find the elements on the page and be able to work out its XPath.

Locators in Selenium IDE





There is different locators we can use to find an element
  •  ID
  •  Name
  •  Link Text
  •  CSS Selector
  •   Tag and ID
  •   Tag and class
  •   Tag and attribute
  •  Tag, class, and attribute
  •  Inner text
  •   DOM (Document Object Model)
  •   getElementById
  •   getElementsByName
  •   dom:name
  •   dom:index
  •  XPath

Eclipse, Selenium Webdriver, Maven, ve Hudson kullanarak CI oluşturma (Continuous Integration Environment) Part 1






 Aşağıdaki adımları izleyebilirsiniz. (You can follow below steps)

1- Oracle ın sitesinden Java JDK indirilir.

You can set JAVA_HOME from here

2- Eclipse i indirmelisiniz buradan.

3- Maven i indirmeli ve kurmalısınız.

4- Hudson indirmelisiniz buradan.



Java JDK_HOME Windows 7

 Aşağıdaki adımları takip ederek JAVA_HOME set edebilirsiniz.

Right-click the My Computer icon on your desktop and select Properties.

Click Advanced system settings link.

Click the Advanced tab.

Click the Environment Variables button.
Under System Variables, click New.

Enter the variable name as JAVA_HOME

Enter the variable value as the installation path for the Java Development Kit as something like this C:\Program Files\Java\jdk1.6.0_45



Android MonkeyRunner Nedir





    MonkeyRunner Android SDK ile gelen bir araçtır ve Python scriptlerini kullanarak otomasyon yapılmasını sağlar. Android in kendi sitesdinde de giriş amaçlı olarak hakkında bilgiye ulaşabilirsiniz.

MonkeyRunner API yı başlıca 3 tane module sahiptir. Bunlar

MonkeyRunner :utility methodlarını barındırır ve cihaza  yada emulator e bağlanmayı sağlar.

MonkeyDevice: emulator u temsil eder ve paketleri installing  uninstalling , Activity i başlatma işlemlerini yapar.

MonkeyImage:  screenshot alabilmemizi sağlar.





Robotium Tutorial 1

İlk olarak buradan gerkli Robotium.jar ını indirmeliyiz.

Daha sonra burada örnek projeyi indirip eclipse projemize import etmeliyiz aşağıdaki gibi gözükmelidir.

File --> Import --> Existing Project into workspace --> Select archive file --> ExampleTestProject_v5.1.zip



Test projesi unit test olarak çalıştırılmalıdır.



Otomoatik olarak adımların çalıştığını görmelisiniz.








Android Robotium Test







Robotium automatic black-box test case ler hazırlanmasını kolaylaştırmak için kullanılan bir framework tur. Para ödemenize gerek yoktur ve user interaction dediğimiz senaryoları otomatize hale getirmemizi sağlar.

Hangi komponentleri destekler diye soracak olursak.

Activity, 
Dialog, 
Toast, 
Menu ve 
Context Menu diyebiliriz.

Geliştirme Ortamı 
  • Eclipse
  • ADT (Android Development Kit)
  • Android SDK (Software Development Kit)
  • JDK (Java Development Kit)
  • En son Robotium Jar dosyası
 JUnit test framework unu kullanır.

Maven ve Ant gibi tool lar ile entegre edilebilir.


Özellikleri


 Robotium ile ekran görüntüsü alınabilir.
 Kaynak koda gerek yoktur.
 Code coverage raporu alınabilir.
 Komut satırı ile çalışılabilmektedir.
 Toast mesajındaki içerik yakalanabilmektedir.


Friday, 25 April 2014

Jenkins Github Plugin and Integration

Manage Jenkins -> Manage Plugins yolu izlenerek Git plugin i bulunur.

Aşağıda yükleme işlemi gözüküyor


  •  Tomcat restart

 Jenkins konfigurasyondan JDK , Maven ve Github path leri set edilir.

 
github dan bir proje url aldım https://github.com/itcuties/Axis-2-client.git


 devam edecek....















Jenkins Installation (Kurulum)


First of all you can download the necessary war file from here

start tomcat


  
  •  Deploy WAR file  in tomcat 



Navigate to   http://localhost:8080/jenkins/ 











Git Kurulumu


İlk olarak buradan git in ilgili sürümünü indirebilirsiniz.



Kurulum tamamlandıktan sonra ekran görünütüsü aşağıdaki şekildedir

                             









Thursday, 24 April 2014

Amazon DynamoDB nedir

Amazon tarafından cloud sistemler için önerilen NoSQL veritabanıdır.

Bir DynamoDB tablosunda veri miktarı limiti yoktur otomatik olarak alan yonetimi yapılır

Amazon tarafından yönetilen bir servistir.



Waterfall Modeli

• Basit bir yapıya sahiptir.Kullanımı ve anlamaşılması kolaydır.
• Tüm fazlar ayrı değerlendirildiğinden yönetimi daha kolaydır.
• Gereksinimlerin iyi belirlendiği küçük projelerde iyi sonuçlar vermektedir.


Waterfall(şelale) modelini ne zaman kullanabiliriz ?

• Gereksinimler tam belirlenmiş ve anlaşılır olduğunda
• Ürün tanımı tutarlı olduğunda
• Teknoloji anlışır olduğunda
• Kısa süreli projelerde

Capability Maturity Model (CMM) Seviyeleri







CMMI da 5 tane seviye vardır sırası ile aşağıdaki gibidir.
  1. Initial
  2. Managed
  3. Defined
  4. Quantitatively Managed
  5. Optimizing

Sahi Test Proxy IE

  •  Tools > Internet Options > Connections > LAN Settings >
  • “Proxy server” da “Use a proxy server for your LAN” i işaretleyin
  • “Advanced” i seçin
  •  HTTP: için “Proxy address to use” değerlerini “localhost” ve “Port”  “9999” yapın
  • “Bypass proxy server for local addresses”işaretlemeyin
  • OK > OK

Tuesday, 22 April 2014

JMeter Elementleri


  Test Plan
v  Thread Group
v     Controllers & Samplers
v     Listeners
v     Timers
v     Assertions
v     Configuration tool
v     Pre-processor elements
v     Post-processor elements
 
 Test Plan : Run edildiğinde çalıştırılacak adımlar dizisidir.

Controller : 


Samplers JMeter server a istek yollar ve cevap bekler.
                                            örnek. HTTP Request sampler.
 
 
  Logical Controllers:  Server a ne zaman istek gönderileceğine karar veren mekanizmadır.
 
  Listeners JMeter çalışırken toplanan bilgilere ulaşmayı sağlar.

 
 
 

JMeter Test Plan









 Ekle -> User -> İş Parçacığı Grubu ile aşağıdaki ekran açılır.

                                      







 Ekle -> Örnekleyici -> HTTP Request yolu izlenerek aşağıdaki ekran açılır.




 Ekle Kaydetme Denetçisi -> Mantık Denetçisi ile eklenir



Daha sonra Workbench > Add > Non-test Elements > HTTP Proxy Server yolu takip edilerek 

test script kaydedicisi eklenir.



Alt kısımdaki ekle butonuna basarak (exclude)



Enter “.*\.png” pattern, “.*\.gif” pattern and “.*\.ico” pattern  eklenirler


                               


Bundan sonra aşadaki değerler girilerek çalıştırılabilir.

Thread Group seçildikten sonra
            Number of threads –  10
            Ramp up period – değiştirmeyin
            Loop count – 5



Monday, 21 April 2014

JMeter Kurulum






 İlk olarak sistemde java_home tanımlı olmalıdır

Daha sonra  buradan jmeter in size uyan sürümünü indirebilirsiniz.










Jmeter tıklandıktan sonra aşağadaki gibi açılacaktır.