我正在使用供應商開發的網頁(SAP BusinessObjects InfoView登錄頁面),並嘗試識別並選擇頁面上的下拉元素。不管我怎麼努力,我得到一個異常:使用動態幀查找HTML頁面中的元素
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"....'
我已經安裝了Firefox和Firebug的,我可以用Firebug的選擇,給了我關於元素的信息元素。我試圖指定:id,:name,.div,.browser,.frame,...沒有任何更改錯誤。我懷疑內部框架是基於選擇「認證」動態地創建頁面,但我不知道如何檢查/驗證是這種情況。
我已經搜索並嘗試了網站上的大部分建議,沒有任何幫助。
頁有很多的Java代碼,表格等下面是從頁剪斷我試圖尋找元素:
<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>
抱歉所有的編輯/轉貼。感謝賈斯汀柯指針。我已經添加了從頁面完整的HTML,希望它可以幫助 –