Monday 9 June 2014

Setting PATH and CLASSPATH


You can run Java applications just fine without setting the PATH environment variable. Or, you can optionally set it as a convenience.
Set the PATH environment variable if you want to be able to conveniently run the executables (javac.exejava.exejavadoc.exe, and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:
C:\Java\jdk1.7.0\bin\javac MyClass.java
The PATH environment variable is a series of directories separated by semicolons (;). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should have only one bindirectory for the JDK in the path at a time (those following the first are ignored), so if one is already present, you can update that particular entry.
The following is an example of a PATH environment variable:
C:\Java\jdk1.7.0\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem
It is useful to set the PATH environment variable permanently so it will persist after rebooting. To make a permanent change to the PATH variable, use the System icon in the Control Panel. The precise procedure varies depending on the version of Windows:
Windows XP
  1. Select Start, select Control Panel. double click System, and select the Advanced tab.
  2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  3. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Windows Vista:
  1. From the desktop, right click the My Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced tab (Advanced system settings link in Vista).
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Windows 7:
  1. From the desktop, right click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Note: You may see a PATH environment variable similar to the following when editing it from the Control Panel:
%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
Variables enclosed in percentage signs (%) are existing environment variables. If one of these variables is listed in the Environment Variables window from the Control Panel (such as JAVA_HOME), then you can edit its value. If it does not appear, then it is a special environment variable that the operating system has defined. For example, SystemRoot is the location of the Microsoft Windows system folder. To obtain the value of a environment variable, enter the following at a command prompt. (This example obtains the value of the SystemRoot environment variable):
echo %SystemRoot%

Update the PATH Variable (Solaris and Linux)

You can run the JDK just fine without setting the PATH variable, or you can optionally set it as a convenience. However, you should set the path variable if you want to be able to run the executables (javacjava,javadoc, and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:
% /usr/local/jdk1.7.0/bin/javac MyClass.java
To find out if the path is properly set, execute:
% java -version
This will print the version of the java tool, if it can find it. If the version is old or you get the error java: Command not found, then the path is not properly set.
To set the path permanently, set the path in your startup file.
For C shell (csh), edit the startup file (~/.cshrc):
set path=(/usr/local/jdk1.7.0/bin $path)
For bash, edit the startup file (~/.bashrc):
PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH
For ksh, the startup file is named by the environment variable, ENV. To set the path:
PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH
For sh, edit the profile file (~/.profile):
PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH
Then load the startup file and verify that the path is set by repeating the java command:
For C shell (csh):
% source ~/.cshrc
% java -version
For kshbash, or sh:
% . /.profile
% java -version

Checking the CLASSPATH variable (All platforms)

The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be defined through other means, such as the bootstrap class path or the extensions directory.)
The preferred way to specify the class path is by using the -cp command line switch. This allows the CLASSPATH to be set individually for each application without affecting other applications. Setting the CLASSPATHcan be tricky and should be performed with care.
The default value of the class path is ".", meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.
To check whether CLASSPATH is set on Microsoft Windows NT/2000/XP, execute the following:
C:> echo %CLASSPATH%
On Solaris or Linux, execute the following:
% echo $CLASSPATH
If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).
To modify the CLASSPATH, use the same procedure you used for the PATH variable.

Saturday 7 June 2014

Selenium and TestLink Integration

This article will show how to integrate Selenium with Testlink . This integration is nothing more than sending the execution result of the test script for Testlink .
We will create a Java project with the support of testng for creating the test script with Selenium . Below is a list of items needed for this tutorial.

PreRequisites:
Install Testlink version 1.9
dbfacade-Testlink-api-client
IDE for Java development(Eclipce)
Java JDK 1.6.0
Libraries Selenium RC Java
Configure TestLink:
Step1:Enable the project with Automation Testing

Step2:Edit the configuration file in Testlink

1)Add below two lines in file custom_config.inc.php.example
$tlCfg-> api-> enabled
$tlCfg-> exec_cfg-> enable_test_automation
2)Rename custom_config.inc.php.example as custom_config.inc.php
Step3:Generate a new key access
After you enable the API access to XML-RPC and report the activation of automation in the configuration file is necessary to generate the key. This key is created by user and that it will allow the Testlink identify who is trying to access the XML-RPC services.
TestLinkHomePage--->MySettings--->AccounSettings--->ApiInterface Section--->Click on Generate a new key.

Preparing Development Environment
Step1:Add the following JAR files in eclipse.

dbfacade-Testlink:
Testlink-client-api-2.0.jar
all libs
Selenium RC:
selenium-server.jar
selenium-java-client-driver.jar

Step2:Sample Source Code.


import java.util.Date;
import com.thoughtworks.selenium.*;
import org.testng.Reporter;
import org.testng.annotations.*;
import testlink.api.java.client.TestLinkAPIResults;
public class Selenium_Methods implements IConstantes {
Selenium selenium;
@Parameters({"selenium.host","selenium.port","selenium.browser","selenium.url"})
@BeforeMethod(alwaysRun=true)
public void startBrowser(String host,String port,String browser,String url){
this.selenium= new DefaultSelenium(host, Integer.parseInt(port), browser, url);
this.selenium.start("captureNetworkTraffic=true, addCustomRequestHeader=true,captureNetworkTraffic=true");
this.selenium.open(url);
} //startBrowser();
@Test public void limitedSearch() throws Exception {
String resultado = null;
String nota = null;
try
{
selenium.open("/");
selenium.click("link=Login");
selenium.waitForPageToLoad("30000");
selenium.type("login", "bala");
selenium.type("password", "krishna");
selenium.click("Submit");
selenium.waitForPageToLoad("30000");
if(selenium.isTextPresent("Welcome balakrishna"))
Reporter.log("Successfully log in");
else
Reporter.log("Error on page");
selenium.click("link=Limited Search Member");
selenium.waitForPageToLoad("30000");
selenium.type("email", "10");
selenium.click("//input[@type='submit']");
selenium.waitForPageToLoad("30000");
selenium.click("link=Logout");
selenium.waitForPageToLoad("30000");
resultado = TestLinkAPIResults.TEST_PASSED;
}
catch (Exception e) {
resultado = TestLinkAPIResults.TEST_FAILED;
nota = e.getMessage();
e.printStackTrace();
}
finally {
ResultadoExecucao.reportTestCaseResult1(PROJETO, PLANO, CASO_TESTE1, BUILD, nota, resultado);
}
}
@AfterMethod(alwaysRun=true)
public void stopSelenium() {
Date dt;
dt = new Date();
System.out.println("Execution Terminated at "+ dt);
this.selenium.stop();
} //stopSelenium();
}

Step3:Class ResultadoExecucao

Within the project create ResultadoExecucao class, which is responsible for sending the result of the script to Testlink.
import testlink.api.java.client.TestLinkAPIClient;
import testlink.api.java.client.TestLinkAPIException;
public class ResultadoExecucao implements IConstantes {
public static void reportTestCaseResult1(String projetoTeste, String planoTeste, String casoTeste, String nomeBuild, String nota, String resultado) throws TestLinkAPIException {
TestLinkAPIClient testlinkAPIClient = new TestLinkAPIClient(DEVKEY, URL);
testlinkAPIClient.reportTestCaseResult(projetoTeste, planoTeste, casoTeste, nomeBuild, nota, resultado);
}

Step4:Interface iConstantes

Create an interface with the data necessary to send the data to the Testlink, which are the parameters that were described above.
public interface IConstantes {
final String DEVKEY = "7c0893a8c63d2599074a308de09ad75b";
final String URL = "http://localhost:82/testlink/lib/api/xmlrpc.php";
final String PROJETO = "SeleniumIntegrationWithTestlink";
final String PLANO = "LCLT001-IntegratingSelenium";
final String BUILD = "integarationbuild1";
final String CASO_TESTE1 = "LimitedSearch";
}

Here DEVKEY =generated API KEY
PROJETO = Project name in Testlink.
PLANO =TestPlan Name
BUILD=Build Name
CASO_TESTE1=TestCaseName

Step5:After Execution,the Result will be automatically reflected to TestLink as below.




Tuesday 3 June 2014

Beginer's Guide On Selenium - 1

Introduction to selenium


What does selenium do ? 
You can use opensource(ie free!) - Selenium tool ( selenium IDE is a plugin to firefox) to record and playback tests (like WinRunner, QTP). You can then export the recorded test in most language e.g. html, Java , .net , perl , ruby etc. The exported test can be run in any browser and any platform using "selenium remote control". 

Selenium Flash Demo(Highly recommended for beginners) : 
http://wiki.openqa.org/download/attachments/400/Selenium+IDE.swf?version=1

What are the components of selenium ? 

Selenium IDE - Plugin to Firefox to record and play test in firefox
and also export tests in different languages. The most appealing
format is the html test case which seems to based on fit html.
Selenium RC- Allows playing of exported test in different platform/OS
Selenium Grid - Allows to control lots of selenium machines(you typically dont need this only for load test -and hence may ignore it)..

Other Project Management/wrapper tools around selenium:

How does Selenium remote control internally works ? 
Selenium RC launches the browser with itself as the proxy server (hence you may get certificate warning in some modes) and then it injects javascript - to play the test. This also means it can easily work in ALL browsers/platform - and it can be easily used to test AJAX(unlike professional tools). 




Monday 2 June 2014

adsense eligibility Criteria

Google adsense being the giant in online advertising,it’s the dream of every blogger or website owner to get his/her adsense account approved.There are certain conditions you have to check regarding your wesite or blog before you apply for adsense approval.Bloggers from USA,canada and europe  gets adsense approval quickly compared to india,china.

The minimum requirements


You should post atleast 10 to 20 content rich pages before applying.
You must be atleast 18years old.
Your site should have a good navigation system that can link all the pages of the blog from the homepage.
Include an about author page with your original photo.
Copyright your content.You can signup in myfreecopyright to copyright your contents for free.

Get some daily visitors through google search.I think the pageviews are not given much consideration.The content is all.
Your website or blog should be atleast 6 months old.(newly blogs only from europe,usa,canada are accepted).
Your site should not contain any adult content.
Your site should not contain any copyrighted pictures,videos or links to sites that violate google policies and guidelines.

Never copy and paste content from other websites.Always post new original content.write content rich pages.