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

StackOverflow https://stackoverflow.com/questions/21533962

  •  06-10-2022
  •  | 
  •  

質問

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"}

役に立ちましたか?

解決

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/)

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top