Accessing elements from within a iFrame -fails in watir-webdriver 0.6.6 - works fine in 0.6.4

≡放荡痞女 提交于 2019-12-01 10:28:24

问题


I am trying to select a value in a dropdown which is inside a iFrame. The frame is nested within a table. HTML:

<html class ="some text"> 
<head>...</head> <body id="htmlBody"> 
 <div class= "modalWindow ui-dialog-content ui-widget-content ModalWindow containsFrame" id="ui-id-2"> 
   <iframe src= "/MyApplicantPortal/Applicant/254471/SelectOrderTemplate?t=1"> 
   #document 
    <html class = "some text" 
     <head id= "Head1"> 
     <body id="htmlBody"> 
     <form method= "post" action="SelectOrderTemplate?t=1" id="form1"> 
      <div class = "ModalContent"> 
       <Table> 
        <td class="label1"> 
         <Select id= "MyselList" </td>

My code:

element(:select_frame, :frame, :src => MyApplicantPortal\/Applicant\/\d+\/SelectOrderTemplate\?t=1/)
select_list(:template) {select_frame_element.select_list_element(:id => 'MyselList')}

Error: Watir::Exception::UnknownFrameException: unable to locate frame using {:src=>/MyApplicantPortal\/Applicant\/\d+\/SelectOrderTemplate\?t=1/, :tag_name=>"frame"}


回答1:


Watir-webdriver 0.6.5 has changed the way locating frames works.

  • Before (ie pre-0.6.5), browser.frame located frame and iframe elements.
  • Now, browser.frame locates frame elements and browser.iframe locates iframe elements.

You will need to change your frame accessor to match the new rules (when you migrated to 0.6.5 or later). The second parameter needs to change from :frame to :iframe:

element(:select_frame, :iframe, :src => /MyApplicantPortal\/Applicant\/\d+\/SelectOrderTemplate\?t=1/)



回答2:


I am in the process of releasing a new version of the page-object gem that addresses this issue. Should be out in a day or two.



来源:https://stackoverflow.com/questions/21533962/accessing-elements-from-within-a-iframe-fails-in-watir-webdriver-0-6-6-works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!