I writing an automation script using Java and TestNG Framework. I am having difficulty to identify the element which is inside the iframe.
Code:
WebElement iframeSwitch= driver.findElement(By.id("configFrame"));
driver.switchTo().frame(iframeSwitch); System.out.println("Switched");
driver.findElements(By.xpath("//input[@ng-change='ProcessUpdates(m);']")).clear();
driver.findElement(By.xpath("//input[@ng-change='ProcessUpdates(m);']")).sendKeys("Arsenal");
driver.findElement(By.id("SearchAll")).click(); Thread.sleep(15000);
driver.switchTo().defaultContent(); JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("javascript:window.scrollBy(0,300)");
I am using
driver.switchTo().defaultContent();
to perform the action on the element which is inside iframe.
I am trying to identify the element using XPath. Selenium IDE is could find my element, but when I used the same XPath in script in TestNG it was unable to locate the element.