Monday, 17 December 2012

Get links testing

import com.thoughtworks.selenium.DefaultSelenium;


public class getlinkstesting {

   
    public static void main(String[] args) throws Exception
    {
        String x;
        DefaultSelenium s=new DefaultSelenium("localhost",1111,"*firefox","http://www.google.co.in");
        s.start();
        s.open("/");
        s.windowMaximize();
        s.type("q","testing");
        s.click("btnG");
        Thread.sleep(5000);
        int n=s.getXpathCount("id('rso')/x:li").intValue();
        for(int i=1;i<=n;i++)
        {
            x=s.getText("xpath=id('rso')/x:li["+i+"]/x:div/x:h3/x:a");
            System.out.println(x);
       }
    }
}

No comments:

Post a Comment