Unable to locate a object with span tag | Selenium Forum
M
Posted on 20/01/2016
hi sir
am unable to locate a object with span tag
tried this box.findElement(By.xpath("//*[contains(@span,2)]")).click();
n box.findElement(By.xpath("//*[contains(@span,'2')]")).click();
firepath gives me this :<span class="cwbts">2</span>
what do i change in xpath?
--------------------------------------------
//my code

w.get("https://www.google.co.in/?gfe_rd=cr&ei=sC2fVqOHNsb2vQTi17G4AQ&gws_rd=ssl#q=calculator");
w.manage().timeouts().pageLoadTimeout(50,TimeUnit.SECONDS);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement box=w.findElement(By.xpath("html/body/div[1]/div[5]/div[4]/div[7]/div[1]/div[3]/div/div[2]/div[2]/div/div/ol/div[1]/div[1]"));


//box.findElement(By.xpath("//*[contains(@span,'2')]")).click();
box.findElement(By.xpath("//*[contains(@span,2)]")).click();
//box.findElement(By.name("2")).click();
//box.findElement(By.linkText("2")).click();
//box.findElement(By.partialLinkText("2")).click();

M
Replied on 20/01/2016

R webtable concept should be used sir?


M
Replied on 22/01/2016

what are you trying to do? please send a screen shot.