Back To Normal

Subscribe To Our E-Mail Newsletter

Tuesday, August 21, 2012

Export - Import in Internet Explorer using Selenium Web Driver


Handling Export and Import by using Keys.
WebElement link = driver.findElement(By.xpath("myxpath"));
ExportAndSaveFileInIE(link, Path);

public static void ExportSaveFileInIE(WebElement element,String sFilepath) throws

InterruptedException{
    try {

      Robot robot = new Robot();
       //Focus the Element
       element.sendKeys("");

      //Press Enter Key to populate Window          
      robot.keyPress(KeyEvent.VK_ENTER);
      robot.keyRelease(KeyEvent.VK_ENTER);
   
      //Wait For Dialog        
      Thread.sleep(2000);

     //press s key to save          
      robot.keyPress(KeyEvent.VK_S);
      robot.keyRelease(KeyEvent.VK_S);
      Thread.sleep(2000);
     //press enter to save the file with specified name and in location
     sFilepath = sFilepath.ToUpperCase()
     for (int i=0;i<=sFilepath .length();i++)
     {
      Char ch = sFilepath.ChartAt(i);
      int iascvalue = ch;
      switch(ch)
{
      Case ":"
       robot.keyPress(KeyEvent.VK_SHIFT);
       robot.keyPress(KeyEvent.VK_COLON);
       robot.keyRelease(KeyEvent.VK_COLON);
       robot.keyRelease(KeyEvent.VK_SHIFT);
      Case "\"
    ....
      default
        robot.keyPress(iascvalue );
      robot.keyRelease(iascvalue );
}

     }
     robot.keyPress(KeyEvent.VK_ENTER);
     robot.keyRelease(KeyEvent.VK_ENTER);

 } catch (AWTException e) {

            e.printStackTrace();
  }

Read More


Thursday, August 16, 2012

Triggers


Oracle lets you define procedures called triggers that run implicitly when an INSERT, UPDATE, or DELETE statement is issued against the associated table or, in some cases, against a view, or when database system actions occur. These procedures can be written in PL/SQL or Java and stored in the database, or they can be written as C callouts.

Triggers are similar to stored procedures. A trigger stored in the database can include SQL and PL/SQL or Java statements to run as a unit and can invoke stored procedures. However, procedures and triggers differ in the way that they are invoked. A procedure is explicitly run by a user, application, or trigger. Triggers are implicitly fired by Oracle when a triggering event occurs, no matter which user is connected or which application is being used.

Examples:

CREATE TRIGGER schema.trigger_name
    BEFORE
    DELETE OR INSERT OR UPDATE
    ON schema.table_name
       pl/sql_block
Read More


Monday, August 13, 2012

Java : Test Automation Questions and Answers

1. String Immutable
The absolutely most important reason that String is immutable is that it is used by the
class loading mechanism, and thus have profound and fundamental security aspects.

Had String been mutable, a request to load "java.io.Writer" could have been changed to load
"vijay.co.DiskErasingWriter"
Details: http://javarevisited.blogspot.in/2010/10/why-string-is-immutable-in-java.html

2. Two main mehod in single class

Ans : Its possible with different retun type and parameters (method overloading )
3. String Memory allocation vs StringBuffer vs String Builders

String sname ='vijay';

sname ='ragavan';
Details: http://javarevisited.blogspot.in/2011/07/string-vs-stringbuffer-vs-stringbuilder.html

5. Usage of Interface
Often interfaces are touted as an alternative to multiple class inheritance. While
interfaces may solve similar problems, interface and multiple class inheritance are quite
different animals, in particular:
A class inherits only constants from an interface.
A class cannot inherit method implementations from an interface.
The interface hierarchy is independent of the class hierarchy. Classes that implement the
same interface may or may not be related through the class hierarchy. This is not true for
multiple inheritance.

Usage of Interfaces :
You use an interface to define a protocol of behavior that can be implemented by any class
anywhere in the class hierarchy. Interfaces are useful for the following:
Capturing similarities between unrelated classes without artificially forcing a class relationship
Declaring methods that one or more classes are expected to implement
Revealing an object's programming interface without revealing its class. (Objects such as these are called anonymous objects and can be useful when shipping a package of classes to other developers.)
6. Garbage collector in java and usage.
Java takes a different approach; it handles deallocation for you automatically. The technique that accomplishes this is called garbage collection. It works like this: when no references to an object exist, that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed.
The finalize( ) Method
Sometimes an object will need to perform some action when it is destroyed. For example, if
an object is holding some non-Java resource such as a file handle or window character font,
then you might want to make sure these resources are freed before an object is destroyed

Keyword: System.gc();
Read More


Thursday, August 2, 2012

How to Clear cookies from internet Explorer by selenium webdriver?:


User can enable Ie capabilities then clear cookies 

DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); WebDriver driver = new InternetExplorerDriver(caps);
driver.manage().deleteAllCookies()

If above one is not woking then U can go for Windows command level clearnace:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Java : Runtime.getRuntime().exec("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2");

Read More


Different Types of drivers in Selenium Web Driver


HtmlUnit Driver
FireFox Driver
Internet ExplorerDriver
Chrome Drivers.

 In details of these drivers , U can go through following links,
  --http://marakana.com/bookshelf/selenium_tutorial/selenium2.html
Read More


Selenium Web driver : Implicit and Explicit Wait

Implicit wait :

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);


Explicit Wait: 

Wait<WebDriver> wait = new WebDriverWait(driver, 30);
WebElement element= wait.until(visibilityOfElementLocated(By.id("some_id")));
Read More


560 Free Online Courses

Top 200 universities launched 500 free online courses.  Please find the list here .