Hi,
Please help me to found the xpath of a element it comes under frameset ... Look into attached sheet for better understand..
Logic : -
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Care {
static WebDriver driver;
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","D:\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://172.19.4.64/MR29/CMS/");
driver.findElement(By.xpath("//*[@id='txtUserName']")).sendKeys("careteststh");
driver.findElement(By.xpath("//*[@id='txtPassword']")).sendKeys("irctc@116");
driver.findElement(By.xpath("//*[@id='btnLogin']")).click();
List<WebElement> frame = driver.findElements(By.name("contents")); =====>> Search the frame with the name.
System.out.println("Frame Counts are -- > " +frame.size());
driver.switchTo().frame(0);
driver.findElement(By.xpath("//*[@id='treeDirectoryn1']/img")).click();
/*for(int i=0;i<frame.size();i++){
driver.switchTo().frame(i);
int s= driver.findElements(By.xpath("//*[@id='treeDirectoryn1']/img")).size();
System.out.println(s);
driver.switchTo().defaultContent();
}*/
}
}
NOTE:- [b:1z42t9gs]System.out.println("Frame Counts are -- > " +frame.size()); ====>> Display only One frame over here. When i use for loop to know that this frame is present on which frame then the out put display 0.
So not able to find the exact frame of that component.[/b:1z42t9gs]