2011-10-27 13 views
7

के अंदर अवधि के लिए XPath अभिव्यक्ति प्राप्त करने में सहायता की आवश्यकता है IFrame के अंदर अवधि के लिए xpath अभिव्यक्ति प्राप्त करने की आवश्यकता है। किसी इफ्रेम पॉपअप के अंदर अवधि के लिए XPath अभिव्यक्ति प्राप्त करने में सहायता चाहिए।किसी इफ्रेम पॉपअप

मैं iframe लेकिन आइफ्रेम कोई मदद नहीं हो रहा है अंदर हो रही है/html/शरीर प्राप्त कर सकते हैं

<div class="gwt-PopupPanelGlass" style="position: absolute; left: 0px; top: 0px; visibility: visible; display: block; width: 1680px; height: 222px;"></div> 
<div class="gwt-PopupPanel" style="left: 439px; top: 0px; visibility: visible; position: absolute; overflow: visible;"> 
<div class="popupContent"> 
<div class="ph-PopupDialog" style="position: relative; width: 800px; height: 220px;"> 
<div style="position: absolute; z-index: -32767; top: -20ex; width: 10em; height: 10ex;">&nbsp;</div> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;"> 
<div style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"> 
<div style="position: absolute; z-index: -32767; top: -20ex; width: 10em; height: 10ex;">&nbsp;</div> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; height: 32px;"> 
<div style="position: absolute; overflow: hidden; left: 0px; top: 32px; right: 0px; bottom: 0px;"> 
<div class="ph-PopupDialog-content" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"> 
<div style="position: absolute; z-index: -32767; top: -20ex; width: 10em; height: 10ex;">&nbsp;</div> 
<div style="position: absolute; overflow: hidden; left: 5px; top: 5px; right: 5px; bottom: 5px;"> 
<div style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"> 
<div> 
<iframe class="gwt-Frame ph-PaymentFrame" name="paymentFrame" src="javascript:''"> 
<html> 
<head> 
<body onload="pageLoaded();"> 
<div class="ph-View"> 
<div class="container_24 form-grid"> 
<div class="container_24 form-grid"> 
<div class="container_24 form-grid"> 
<div class="container_24 form-grid"> 
<div class="container_24 form-grid"> 
<div class="grid_12"> 
<div class="ph-ButtonPanel ph-ButtonPanel-undecorated"> 
<a class="ph-Button ph-Button-button" onclick="submit();return false;" style="float: right; margin-left: 5px;" href="#"> 
<a class="ph-Button ph-Button-button" onclick="cancel();return false;" style="float: right; margin-left: 5px;" href="#"> 
<span>Cancel</span> 
</a> 
</div> 
</div> 
</div> 
</div> 
</body> 

`

उत्तर

1

उपयोग:

//iframe//span 

यह हर span तत्व XML दस्तावेज़ में किसी भी iframe तत्व के वंशज है कि चयन करता है।

0
//span [ancestor::iframe] 

यह कुछ बिंदु पर सभी स्पान तत्व जो चुन लिए जाएँगे सराहना की जाएगी एक पूर्वजों iframe तत्व है।

8

आईफ्रेम में तत्व वास्तव में किसी अन्य पृष्ठ में हैं। इसलिए आपको पहले उस पृष्ठ का पता ढूंढना चाहिए जो iframe के src value का मान है और इसे लोड करें और उसके बाद उस पृष्ठ में तत्व का उपयोग करें।

var iframe = document.getElementsByTagName("iframe")[0]; 
var theFirstSpan = document.evaluate('//span', iframe.contentDocument, 
     null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue 
5

आपको iframe के contentDocument संपत्ति के लिए xpath के दायरे सेट करना होगा। हमें पहले आईफ्रेम पर जाने की जरूरत है।

मैं PHP फेसबुक वेबड्राइवर का उपयोग कर रहा हूं और यह मेरे लिए पूरी तरह से काम कर रहा है।

$driver->get("http://www.example.com"); // containing an iframe 
$iFrame = $driver->findElement(
      WebDriverBy::xpath('//iframe[@name="iFrameName"]') //name or id or whatever by which we can access. 
     ); 
$driver->switchTo()->frame($iFrame); 

अब, हम है कि span के रूप में,

$spanButton = $driver->findElement(
      WebDriverBy::xpath('//span') 
     ); 

मुझे आशा है कि यह किसी को मदद मिल सकती है उपयोग कर सकते हैं!

-1

हम एक iframe सीधे भीतर तत्वों का उपयोग नहीं कर सकते हैं:

संबंधित मुद्दे