anandmeher / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Need method to switch to iframe context and access elements within it #647

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1.What steps will reproduce the problem?

I have a webview which has an iframe content wrapped in a #document as below. 
Using Robotium, I'm unable to click or find elements within the iframe.

<html> 
   <body>
     <iframe id="iframe_a">
        #document
              ......
              <div id="mydiv"/>
              .....
       </iframe>       
   </body>
</html>

 I'm using solo.clickOnWebElement(By.xpath("//div[@id='mydiv']")

2. What is the expected output? What do you see instead?

I should be able to click on the elements within the iframe document. I get 
element not found if i refer any iframe document elements within my robotium 
code using xpath as above.  
Similar to selenium, we need a method to switch to iframe document and perform 
actions and switch back to parent 

3.What version of the product are you using? On what operating system?

Android 4.4 kitkat
Robotium Solo 5.0.1

4. Please provide any additional information below.
When i look at how the log, i see that Robotium internally uses 
document.evaluate which has the document context as the parameter.  If i set 
the document context to iframe manually as below, within chrome console, i was 
able to access the iframe elements 

document.evaluate("//div", document.getElementById("iframe_a").contentDocument, 
null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue

Original issue reported on code.google.com by rajesh.t...@gmail.com on 2 Jan 2015 at 1:29

GoogleCodeExporter commented 9 years ago
I have fixed it locally 

Original comment by rajesh.t...@gmail.com on 10 Jan 2015 at 12:45

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. Is the iframe_a id a general id for all iframes or 
could the name be something else? 

Original comment by renasr...@gmail.com on 2 Feb 2015 at 5:10

GoogleCodeExporter commented 9 years ago
Thanks for your reaponse. Iframe_a is just the id my application uses. Usually 
in selenium we have methods to switch to a iframe by passing the iframe id . 
Requesting something similar in robotium.

Original comment by rajesh.t...@gmail.com on 3 Feb 2015 at 4:05

GoogleCodeExporter commented 9 years ago
Ok thanks. We will add support for this in the next release. 

Original comment by renasr...@gmail.com on 3 Feb 2015 at 4:14