I am stuck with a problem in automating pages having an iframe,
Scenario here is to Drag and drop element present INSIDE the iframe element which thus cannot be recognized by WebDriver
I am stuck with a problem in automating pages having an iframe,
Scenario here is to Drag and drop element present INSIDE the iframe element which thus cannot be recognized by WebDriver
Option 1: Use CSS Selector or XPath
WebElement iframe = driver.findElement(By.cssSelector(".demo-frame"));
// alternative locators:
// XPath: .//iframe[@class='demo-frame']
// use src attribute
// Css Selector: iframe[src*='demos/draggable']
// XPath: .//iframe[contains(@src, 'demos/draggable')]
driver.switchTo().frame(iframe);
WebElement draggable = driver.findElement(By.id("draggable"));
// do your drag, where do you want to drop?
Option 2: Use index (not recommended)
driver.switchTo().frame(0);
for xpath you have to install firebug and firepath through addons in your Firefox browser.After installing, firebug will be shown on your Navigation bar. you have to just click on that and you can find firepath overthere which will provide you xpath css path etc. with help of inspector.