Not Able to found Xpath using FrameSet | Selenium Forum
M
Posted on 04/06/2016
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]

M
Replied on 05/06/2016

Please suggest.. Waiting for the reply. Responsive image


M
Replied on 05/06/2016

??????? Any Idea about it..


M
Replied on 06/06/2016

i was trying to run your code but the website seems to be internal one.

is there any way for me to access to website?


M
Replied on 06/06/2016

No, You can't access this application this is run on Intranet.
So please suggest me the solution. i am stuck over here from last few days.

Waiting for your reply.


M
Replied on 06/06/2016

create a function isElementPresent(it's explained in the videos) and then loop that with different iframes

that will tell which frame has the xpath.