Hi,

I was facing issues with handling the iFrames in Geb and this approach 
worked for me,:

1. Create a model Page class (for example FrameDescribingPage) , your 
iFrame will be considered as a Page class.
2. Identify your iFrame and define a DSL for it  (example :contentFrame in 
the code below)
3. In the Method where you plan to interact with the page, use 
withFrame(contentFrame)
4. Use Navigator Objects to interact with the contents
example: $("input#Login").value user

Note: in Step 4 , DSL did not work , I had to write the element identifiers 
within the withFrame block


*Example*


import geb.Page

class YouarPageWithIFramesPage extends Page {
    static at = { contentFrame.size() > 0 }

    static content = {
        contentFrame(page: FrameDescribingPage, wait: true) { 
$("iframe[id='MyIframe']") }
    }

    /**
     * Method to interact with Iframe.
     */

    def MethodToInteractWithIframe(String user, String password) {
        withFrame(contentFrame)
                {
                    waitFor{$("input#Login").isDisplayed()}
                    $("input#Login").value user
                    $("input#Password").value password
                    $("button#submit").click()
                }
    }
}

/**
 * model class for page that describes the iframe
 */
class FrameDescribingPage extends Page {
    static content = {
    }
}



Let me know if you face trouble in using the approach.


*Regards*
*Nikhil Jain*


On Tuesday, March 29, 2016 at 12:13:58 AM UTC+5:30, Gopala Krishnan wrote:
>
> I am Automate our internal application in Chrome browser using Geb/Groovy, 
> Our Latest version, all future comes under iFrame. So our existing Script 
> cannot able to click any of the element under iFrame.
> I used Geb & Selenium Syntax to handle the iFrame, 
> withFrame(Index) and (string), 
> driver.switchto.frame() also tried.
> I could not able to click the element.
> Because of this, i could not able to move forward. Could you please help 
> to find the solution.
>

-- 
You received this message because you are subscribed to the Google Groups "Geb 
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/f66cc312-d55f-49bc-9965-220d9d444928%40googlegroups.com.

Reply via email to