Friday, August 23, 2013

selenium xpath ancestor example

The below codes explains how to use xpath ancestor in your selenium code. I wrote code snippet here in java programming language.
import org.openqa.selenium.By;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SeleniumAncestorEx2 {
 public static void main(String[] args) {
  WebDriver driver = new FirefoxDriver();
  driver.get("file:///D:\\ancestor.html");
  WebElement element = driver.findElement(By
    .xpath("//div[@id='div4']"));
  String id=element.getAttribute("id"); 
  System.out.println("required element id" + id); 
  element = element.findElement(By.xpath("./ancestor::div[1]")); 
  System.out.println("above one level the parent element id of id \""+id +"\" is :"+element.getAttribute("id"));
  id=element.getAttribute("id"); 
  element = element.findElement(By.xpath("./ancestor::div[1]")); 
  System.out.println("above one level the parent element id of id \""+id +"\" is :"+element.getAttribute("id"));
  id=element.getAttribute("id"); 
  element = element.findElement(By.xpath("./ancestor::div[1]")); 
  System.out.println("above one level the parent element id of id \""+id +"\" is :"+element.getAttribute("id"));
  element = driver.findElement(By.xpath("//div[@id='div4']"));
  id=element.getAttribute("id");
  element = element.findElement(By.xpath("./ancestor::div[3]"));
  System.out.println("outer most parent div element id of id \""+id +"\" is :"+element.getAttribute("id"));
  
 }  
}

<html>
<body>
<div id="div1">
<div id="div2">
<div id="div3">
<table>
<tr>
<td>
<div id="div4">Ancestor Check</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>
you can save the above html content as ancestor.html and refer that in above java code.
Output:
above one level the parent element id of id "div4" is :div3
above one level the parent element id of id "div3" is :div2
above one level the parent element id of id "div2" is :div1
outer most parent div element id of id "div4" is :div1
You can also refer basic example of ancestor in below link
http://softwares-list.blogspot.in/2013/08/selenium-xpath-ancestor-example.html

Thursday, August 22, 2013

selenium xpath ancestor example

The below codes explains how to use xpath ancestor in your selenium code. I wrote code snippet here in java programming language.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SeleniumAncestorEx {
 public static void main(String[] args) {
  WebDriver driver = new FirefoxDriver();

  driver.get("file:///D:\\ancestor.html");
  WebElement element = driver.findElement(By
    .xpath("//div[@id='innerDiv1']"));

  System.out.println("inner element id" + element.getAttribute("id"));
  element = element.findElement(By.xpath("./ancestor::div[@id='div1']"));
  System.out.println("ancestor element id  : " + element.getAttribute("id"));
 }
}
<html>
<body>
 <div id="div1">
  <table>
   <tr>
    <td>
     <div id="innerDiv1">Ancestor Check</div>
    </td>
   </tr>
  </table>
 </div>
</body>
</html>
you can save the above html content as ancestor.html and refer that in above java code. After running the above program and observing the output, you can clearly understand the usage.

Sunday, September 23, 2012

Apache Shale Framework

Shale is a modern web application framework, fundamentally based on JavaServer Faces. Architecturally, Shale is a set of loosely coupled services that can be combined as needed to meet particular application requirements. Shale provides additional functionality such as application event callbacks, dialogs with conversation-scoped state, a view technology called Clay, annotation-based functionality to reduce configuration requirements and support for remoting. Shale also provides integration links for other frameworks, to ease development when combinations of technologies are required.

To know more about shale framework , visit the following links.


http://shale.apache.org/documentation.html

http://www.developersbook.com/articles/Shale-framework-introduction.php

http://www.javabeat.net/tips/154-what-is-shale-web-framework.html

http://www.devx.com/java/Article/31419/1763/page/2

http://www.jsfcentral.com/articles/mcclanahan-05-05-2.html



Javassist

Javassist (Java programming assistant) is a load-time reflective system for Java. It is a class library for editing bytecodes in Java; it enables Java programs to define a new class at runtime and to modify a class file before the JVM loads it. Unlike other similar systems, Javassist provides source-level abstraction; programmers can modify a class file without detailed knowledge of the Java bytecode. They do not have to even write an inserted bytecode sequence; Javassist instead can compile a fragment of source text on line (for example, just a single statement).

To know more about Javassist , refer the following links.

http://www.jboss.org/javassist

http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/tutorial/tutorial.html