Reputation: 13
I am working with a vendor developed web page (SAP BusinessObjects InfoView login page) and am trying to identify and then select a drop-down element on a page. No matter what I try, I get an exception:
require 'watir-webdriver'
ie = Watir::Browser.new
ie.goto "http://svr-boj-bop-01.mgc.mentorg.com:8080/InfoViewApp"
ie.select_list(:id, "authenticationSelectBox").select("secLDAP")
#=> 'error: "unable to locate element, using :id=>"authenticationSelectBox", :tag_name=>"select"....'
I have FireFox and Firebug installed, I can use Firebug to select the element which gives me info about the element. I've tried to specify :id, :name, .div, .browser, .frame, ... nothing changes the error. My suspicion is that the inner frame(s) is creating the page dynamically, based on the select of the "Authentication", but I don't know how to check / validate that is the case.
I've searched and tried most of the suggestions on the site, nothing is helping.
The page has lots of Java code, forms, etc. Here is a snip from the page I'm trying to search for elements:
<body onload="logonPageLoad()">
<div class="logonContainer">
<div class="logonIFrame">
<iframe id="infoView_home" width="80%" frameborder="0" align="center" title="Log On to InfoView" name="infoView_home" onload="resizeFrameToContent("infoView_home")" src="jsp/listing/blank.jsp" style="height: 287px;">
<html class="logon_body">
<body class="logon_body" onload="loadInit();">
<div class="logon_body">
<div id="logonCredentials">
<form action="../../../PartnerPlatformService/service/app/logon.object" method="POST" name="logonForm">
<div class="logon_table">
<div id="authentication" class="logon_input">
<label class="logon_input_label" onclick="businessobjects.webutil.accessibility.setFocusOnElement('authenticationSelectBox'); return false;" tabindex="-1" for="authenticationSelectBox"> Authentication: < /label>
<select id="authenticationSelectBox" class="logonSelectBox" onchange="SetAuthType(false);resizeFrameToContent('infoView_home')" name="authType">
<option value="secEnterprise" selected=""> Enterprise `</option>
<option value="secLDAP"> LDAP </option>
<option value="secWinAD"> Windows AD </option>
<option value="secSAPR3"> SAP</option>
</select>
Upvotes: 1
Views: 1454
Reputation: 46836
For elements in frames, you have to explicitly call out the frame:
my_frame = ie.frame(:id, "infoView_home")
my_frame.select_list(:id, "authenticationSelectBox").select("secLDAP")
Though it sounds like you might have already tried that. It is possible, that the element is not being loaded before Watir thinks the page is loaded. If that's the case, you can add a wait using something like the when_present
method.
my_frame = ie.frame(:id, "infoView_home")
my_frame.select_list(:id, "authenticationSelectBox").when_present.select("secLDAP")
Note that you can do it in one line (ie you do not need the my_frame
). It is just added to make it easier to read (ie minimize horizontal scrolling).
Upvotes: 2