Accessing elements from within a iFrame -fails in

2020-03-30 09:23发布

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

2条回答
再贱就再见
2楼-- · 2020-03-30 09:49

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.

查看更多
地球回转人心会变
3楼-- · 2020-03-30 10:08

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/)
查看更多
登录 后发表回答