cannot login to iframe based web application. I can't enter user name or password.

160 views
Skip to first unread message

Sri Kanth

unread,
Dec 12, 2017, 1:34:07 AM12/12/17
to Selenium Users
Enter code 
<html><head><title>IBM TRIRIGA</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="SHORTCUT ICON" href="html/en/default/common/getImageFile.jsp?fileLoc=//images/icons/favicon.ico">
<link rel="stylesheet" type="text/css" href="html/en/default/login/login.css">
</head>
<body>
<div id="iframeWrapper">
<iframe src="index.jsp"></iframe>
</div>
</body></html>
<body>
<div id="iframeWrapper">
<iframe src="index.jsp"></iframe>
</div>
</body>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="html/en/default/login/login.css">
<script type="text/javascript">
/**
* Append all the input parameters sent from extRedirect.jsp or other locations and send them to the login_fms.jsp
*/
function setTitle(){
parent.document.title = "IBM TRIRIGA";
}
<body onload="setTitle();">
<div id="main">
<div id="loginWrapper">
<div id="loginBox" style="background-image: url('html/en/default/common/getImageFile.jsp?fileLoc=/images/login_background.png')">
<div id="header">
<div id="loginLogo" style="background-image: url('html/en/default/common/getImageFile.jsp?fileLoc=/images/login_logo.png')"></div>
<div class="clear"></div>
<div id="loginTitle" class="loginTitle" style="">IBM TRIRIGA</div>
</div><!--header-->
<div class="loginContent">
<div id="messageOverlay">
<div id="messageWrapper">
<div id="dialogMessageHeader"></div>
<div id="dialogBody"></div>
<div id="dialogButtonWrapper">
<button id="msgButtonAffirm"></button>
<button id="msgButtonCancel" onclick="dialogCancel()">Cancel</button>
</div>
<div class="clear"></div>
</div>
</div>
<div class="iframeDiv">
<script language="JavaScript">
document.write("<iframe id='loginMain' role='presentation' src='" + getUrl() + "' frameborder='0' hspace='0' marginheight='0' marginwidth='0' scrolling='no' vspace='0' style='width: 100%; height:100%;' title='Login Form' allowTransparency='true'></iframe>");
</script><iframe id="loginMain" role="presentation" src="html/en/default/login/loginMain.jsp" hspace="0" marginheight="0" marginwidth="0" scrolling="no" vspace="0" style="width: 100%; height:100%;" title="Login Form" allowtransparency="true" frameborder="0"></iframe>
</div>
</div> <!-- loginContent -->
<div class="clear"></div>
</div> <!-- loginBox -->
</div> <!-- loginWrapper -->
<div class="clear"></div>
<div id="footerWrapper">
<div id="footer">
<div id="tririgaLegal">
<div>
<p style="margin:0px;margin-top:5px;">
Licensed Materials - Property of IBM (c) Copyright IBM Corp. 1997, 2015 All Rights Reserved. IBM, the IBM logo, ibm.com and TRIRIGA are trademarks or registered trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at <a href="http://www.ibm.com/legal/copytrade.shtml">Copyright and trademark information</a>.
</p>
</div>
<div id="csiImage">
<img src="html/en/default/common/getImageFile.jsp?fileLoc=/images/csi_logo.png">
</div>
<div id="csiLegal">
<p style="margin:0px;margin-top:5px;">
<i>MasterFormat</i><sup>®</sup> is produced jointly by CSI and Construction Specifications Canada (CSC). U.S. copyright is held by CSI and Canadian copyright by CSC. All Rights Reserved. For license information, contact CSI at c...@csinet.org. For more information on MasterFormat visit <a href="http://www.MasterFormat.com">www.MasterFormat.com</a>.
</p>
</div>
<div class="clear"></div>
<div>
<p style="margin-top:0px;margin-top:5px;">Portions copyright (C) Free Software Foundation, Inc 1991, 1999.</p>
</div>
</div> <!-- tririgaLegal -->
</div> <!-- footer -->
</div><!-- footerWrapper -->
</div><!-- main -->
</body>
function getUrl(){
var loginUrl = 'html/en/default/login/loginMain.jsp';
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
if (i == 0){
loginUrl += '?';
}else{
loginUrl += '&';
}
loginUrl += escapeHtml(escapeUrl(key)) + '=' + escapeHtml(escapeUrl(val));
}
}
return loginUrl;
}
function dialogCancel(){
location.reload();
}
</script>
<title>IBM TRIRIGA</title></head>
<div id="loginForm" text-align="left">
<form action="/telms/WebProcess.srv" name="login" method="post" onsubmit="doSubmit()" target="_top" autocomplete="on">
<input name="objectId" value="1000" type="hidden">
<input name="actionId" value="1005" type="hidden">
<input name="screenWidth" type="hidden">
<input name="screenHeight" type="hidden">
<input name="screenDPI" type="hidden">
<input name="contentType" value="/html/en" type="hidden">
<input name="languageId" value="1" type="hidden">
<input name="ieFlag" value="1" type="hidden">
<input name="ExtReqURL" id="ExtReqURL" value="" type="hidden">
<div id="loginEntry" class="loginItem">
<div class="loginLabel">
<label for="USERNAME">User ID:</label>
</div>
<div class="loginField">
<input id="userNameField" size="20" class="loginTextEntry" title="User Name" name="USERNAME" maxlength="700" value="" tabindex="1" aria-label="User Name" type="text">
</div>
</div>
<div class="clear"></div>
<div id="loginEntry" class="loginItem">
<div class="loginLabel">
<label for="PASSWORD">Password:</label>
</div>
<div class="loginField">
<input id="passwordField" size="20" class="loginTextEntry" title="Password" name="PASSWORD" value="" tabindex="2" type="password">
</div>
</div>
<div class="clear"></div>
<div>
<div id="loginSubmit">
<input tabindex="3" value="Log In" title="Log In" class="loginButton" style="" type="submit">
</div>
<div id="loginError">
</div>
</div>
<div class="clear"></div>
</form>
</div>
here...

I could launch the application with chrome browser , but could not sendkeys to username , i tried by id , xpath , cssselector after using switch to frame

Enter code here...package com.realestate.automationframework;

import java.io.File;
import java.util.List;
import java.util.Set;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
import org.testng.annotations.Test;

public class tryTest {
 
@Test
public void realEstateTelms() throws Exception{
try{
final File file = new File("/Users/chrisuser/Documents/workspace/automationframework/Resources/Selenium-Drivers/chromedriver");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());

//driver = new ChromeDriver();
 
// Initialize browser
WebDriver driver=new ChromeDriver();
 
// Open the url

//driver.manage().window().fullscreen();
String currenturl = driver.getCurrentUrl().toString();

String actualTitle = driver.getTitle();
String expectedTitle = "IBM TRIRIGA";
        Assert.assertEquals(actualTitle, expectedTitle);
       Thread.sleep(10000);
    
  //By executing a java script
  JavascriptExecutor exe = (JavascriptExecutor) driver;
 
  Integer numberOfFrames = Integer.parseInt(exe.executeScript("return window.length").toString());
 
 
  //By finding all the web elements using iframe tag
  List<WebElement> iframeElements = driver.findElements(By.tagName("iframe"));
 
 
  //Switch by Index
  try{
  driver.switchTo().frame(0);
  Thread.sleep(10000);
  //driver.switchTo().frame(driver.findElement(By.id("loginMain"))); 
  System.out.println("I could switch to the Frame");
 
  }
  catch(Exception e){
  System.out.println("There is no such Frame ");
  }
 
     
    try{
    System.out.println("ENTERED THE TRY BLOCK TO SEE ELEMENTS");
      
         List<WebElement> elementnames= driver.findElements(By.cssSelector("*"));
   
   
    System.out.println("NUMBER OF WEBELEMENTS" + "  "+elementnames.size());
        
        for(WebElement ele1: elementnames){
        
      String b= ele1.getText();
          System.out.println("TRING TO PRINT WEBELEMENTS " + " " +b);
        
    
         
        }
   
    }
    catch(Exception e){
   
    System.out.println("I can't find any elements");
   
    }
  // loginMain
    
  //    driver.switchTo().frame(driver.findElement(By.id("userNameField"))); 

    
   
  try{
  System.out.println("ENTERED THE TRY BLOCK TO SEE WINDOW HANDLES");
    Set<String> windownames= driver.getWindowHandles();
      
      for(String ele: windownames){
      System.out.println("These are the WebElements" + " "+ele.toString().toUpperCase());
       
      }
 
  }
  catch(Exception e){
 
  System.out.println("I can't find any elements");
 
  }
   
    try{
    driver.findElement(By.id("userNameField")).click();
        driver.findElement(By.xpath("//*[@id='userNameField']")).sendKeys("username");
        driver.findElement(By.id("userNameField")).sendKeys("password");
    }
    
    catch(Exception e){
    System.out.println("NOTHING TO CLICK ON");
   
    }
    
 
    Thread.sleep(5000);

     driver.close();
     driver.quit();
        
}
    finally{
              System.out.println("this is the end of the class");
   
    }

}
}




I have been trying different ways to just login , entering user name and password. I would appreciate your help with code to login.

Anupama

unread,
Dec 20, 2018, 1:01:11 PM12/20/18
to Selenium Users
Hi Sri Kanth,

I am facing the issue. could you please let me know if you were able to fix the issue ? if so please share the fix details.

Thanks,
Anupama
Reply all
Reply to author
Forward
0 new messages