0

I am working on frame based website. I am using selenium 2.47.1 & PhantomJS 1.9.2. I have written Automation Script & run it using firefox driver, it works perfectly. I am trying to execute the code with help PhanthomJS driver. But whenever I am trying to execute the it gives NoSuchFrameFoundException. My script is given below...

public class iFrame {
public String baseUrl = "https://test5.icoreemr.com/interface/login/login.php";
public WebDriver cd;
String scenarioName = "Sheet1";
ExcelLibrary ex = new ExcelLibrary();

@BeforeTest
public void SetBaseUrl() {
    Capabilities caps = new DesiredCapabilities();
    ((DesiredCapabilities) caps).setJavascriptEnabled(true);                
    ((DesiredCapabilities) caps).setCapability(
            PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
            "C:\\Users\\Probe7\\Downloads\\phantomjs-1.9.2-windows\\phantomjs.exe"
        );
    this.cd = new PhantomJSDriver(caps);
    cd.get(baseUrl);
    cd.manage().window().maximize();
}

 @Test(priority = 0)
/* Login into the Application */
public void Login()  {
     cd.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
     cd.switchTo().frame("Login");
     System.out.println("Control Moved to Login Frame");
     String UserName = ex.getExcelValue(scenarioName, 2, 4);
     cd.findElement(By.xpath("//body/center/form/table/tbody/tr/td/div/div[2]/table/tbody/tr[1]/td[2]/input")).sendKeys(UserName); 
} 

Above code gives following exception..

org.openqa.selenium.NoSuchFrameException: No frame element found by name or id Login

Eventhough same script works perfectly in firefox driver, but not in PhantomJS. Please advice me what went wrong?? I am looking into this nearly a day, but didn't find any solution.. Please help me on this? Thanks in Advance...

Karthik
  • 87
  • 1
  • 5
  • 12
  • Are you sure that you're on the correct page? Have you taken a screenshot or printed the page source to see if the login frame is there? Also, you might want to update to PhantomJS 1.9.8 or 2.0.0. – Artjom B. Sep 14 '15 at 12:23
  • I have tried PhantomJS 2.0.0 also but it gives the same exception. I'm sure that Login Frame is available from the baseUrl given in above code – Karthik Sep 14 '15 at 12:51
  • Try to take a screenshot of the webpage just before the switch to iframe and see if everything is being loaded correctly. This [answer](http://stackoverflow.com/a/3423347/3122880) should help you on that. – Vikas Ojha Sep 14 '15 at 13:55
  • I have used following code to take screenshot. But it is not working.. `File src = ((TakesScreenshot) cd).getScreenshotAs(OutputType.FILE); System.out.println("File:" + src); FileUtils.copyFile(src, new File("E:\\temp\\screenshot_" + count++ + ".png"));` IS this correct way or not? – Karthik Sep 14 '15 at 14:16
  • I changed the baseUrl to "http://localhost/icoreemr/interface/login/login_frame.php". I am directly called login frame, In LocalHost it works perfectly & Login got passed. But in Server for this URL "https://test5.icoreemr.com/interface/login/login_frame.php" gives NoSuchFrameException – Karthik Sep 15 '15 at 09:39

0 Answers0