Handling
Tables with same ID and Name
If
in a page there are more then one table with same name and id, then
we can identify each table using position is selenium
For
example
- Go to "http://www.icicidirect.com". Click on the Markets Link
- Here we will find two tables Top Gainer and Top Losers with same id.
- We can identify each table uniquely using position
Below
is the code
public
static
DefaultSelenium ds
= null;
public
static
SeleniumServer server
= null;
public
static
void
selecttable()
{
String
str;
start("http://www.icicidirect.com");
// function to launch url
Thread.sleep(3000);
ds.click("link=Markets");
Thread.sleep(5000);
str=ds.getTable("xpath=(//*[@class='tabData
bdr_btm brd'])[position()=2].3.1");
System.out.println(str);
}
public
static
void
start(String url) throws
Exception
{
rc=new
RemoteControlConfiguration();
rc.setPort(1111);
server
= new
SeleniumServer(rc);
server.start();
ds=new
DefaultSelenium("localhost",1111,"*firefox",url);
ds.start();
ds.windowMaximize();
ds.open("/");
}
0 comments:
Post a Comment