I am unable to locate a frame inside an iframe. I have attached the screenshot of the html page.
I am able to locate iframe 'content' by xpath //div[@id='pageContentDiv']//iframe
which I verified in chrome and my code is working.
WebElement frame1 = driver.findElement(By.xpath("//div[@id='pageContentDiv']//iframe"));
driver.switchTo().frame(frame1);
but unable to locate the frame 'detailsDisplay'.I tried //div[@id='pageContentDiv']//iframe//frame[@name='detailsDisplay']
but unable to locate in chrome. My motive is to locate the 'Part Details' link element inside the 'detailsDisplay' frame.
Full code.
public WebDriver createPart() {
try {
driver.findElement(By.id("username")).sendKeys("502409373");
driver.findElement(By.id("password")).sendKeys("Magic14Magic");
driver.findElement(By.id("submitFrmShared")).click();
//Thread.sleep(10000);
driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(70, TimeUnit.SECONDS);
Select dropCountry = new Select(driver.findElement(By.id("txtNewLocation")));
dropCountry.selectByVisibleText("India");
driver.findElement(By.xpath("//button[@class='btn']/label")).click();
driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(70, TimeUnit.SECONDS);
//driver.findElement(By.xpath("//span[@class='ds-coachmark-close']")).click();
//driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
//driver.manage().timeouts().pageLoadTimeout(70, TimeUnit.SECONDS);
Thread.sleep(10000);
String parentWindowHandler = driver.getWindowHandle(); // Store your parent window
driver.findElement(By.xpath("//li[@class='icon-button add']/span")).click();
driver.findElement(By.xpath("//div[@id='ENCActions']/a/label")).click();
driver.findElement(By.xpath("//label[starts-with(text(),'Create Part...')]")).click();
driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(70, TimeUnit.SECONDS);
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles(); // get all window handles
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
System.out.println("k1");
}
System.out.println(driver.switchTo().window(subWindowHandler).getTitle());
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = driver.findElement(By.xpath("//select[@id='Type-Field']//following-sibling::div//div//input"));
element.click();
Thread.sleep(3000);
element.sendKeys(Keys.BACK_SPACE);
Thread.sleep(3000);
element.sendKeys("Subassy");
Thread.sleep(4000);
driver.findElement(By.xpath("//div[@data-value='Subassy']")).click();
driver.findElement(By.xpath("//span[text()='Description']//parent::td//following-sibling::td//textarea")).sendKeys("Testing");
driver.findElement(By.xpath("//option[text()='BioSc-DS-Chemical']//parent::select")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//option[text()='BioSc-DS-Chemical']")).click();
driver.findElement(By.xpath("//a[text()='Done']")).click();
driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(70, TimeUnit.SECONDS);
System.out.println(driver.switchTo().window(parentWindowHandler).getTitle());
driver.switchTo().frame("content");
driver.switchTo().frame("detailsDisplay");
driver.findElement(By.xpath("//a[@title='Part Details']")).click();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return driver;
}
I am adding 2 screenshots. In the first screenshot I am able to locate the iframe 'content'. In the second screenshot, I am unable to locate the 'detailsDisplay' frame (HTML code is not getting highlighted) by xpath //div[@id='pageContentDiv']//iframe//frame[@name='detailsDisplay']
Is there anything issue with the html tag and document tags in the code ? I am struggling with this issue quite a longtime. Please suggest some solutions.