Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Java recursive Fonction selenium

  1. #1
    Junior Member
    Join Date
    Sep 2019
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java recursive Fonction selenium

    Hello all , i am working on a java automatisation project using selenium web driver; this project should work on any application/any site (which is hard). i done a good job until now , but my Bigest problem since a month is this:
    Since every web page can contains infinite number of frames : selenium needs to search in all the iframes of the page to find the element : here is an exemple of a web page to help you understand me :




    xxx.png
    I need to create a java fonction like this:
    List<WebElement> iframes = driver.findElements(By.tagName("iframe"));
    for (WebElement iframe : iframes) {

    }
    How i do to search in all the iframes recursively ? u understand please guys? i need to enter all the frames and search my element there!!!
    PLease try to help , even a little idea might keep me my job

    Thank you all in advance

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Java recursive Fonction selenium

    How i do to search in all the iframes recursively
    Why recursive? Why not iterate a loop?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2019
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java recursive Fonction selenium

    how iterate man? imagine a web page contain 4iframes: and each iframe contains 20other iframes , and those 20iframes contains each one 10iframes , i mean its infinite loop. thats why i need a recursive thing to iterate all the iframes of the web page

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Java recursive Fonction selenium

    What have you tried? Can you post the code you are working with?

    How would anyone test the code? Do you have any sample input for testing?

    Is the structure like a file system on a computer? If so look at the search methods for looking at all the files in a folder that contains other folders.

    --- Update ---

    Also posted here: https://www.dreamincode.net/forums/t...tion-selenium/
    and here: https://coderanch.com/t/717043/java/...lenium#3351336

    Please read this: http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2019
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java recursive Fonction selenium

    bro sry the code is at my pc at job , but please try understand:
    List<WebElement> iframes = driver.findElements(By.tagName("iframe"));
    this will return only the global frames: like in the image in my question(frame1,2,3 and frame) , not the inside ones (frame1.1,frame3.1....).

    Lets make it east forget selenium all together: now a pure java question :
    imagine you have this:
    public class frame{
    List<frame> lst;
    }
    now you have an object of this class frame, question is check the latest frame in this object means :
    frame
    -------------> frame1
    -------------> frame2
    -------------> frame3-------->frame4
    ------>frame5
    you understand? each frame contains another list<frame> and the question is to loop until you find the lastest frame

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Java recursive Fonction selenium

    Is the structure like a file system on a computer? If so look at the search methods for looking at all the files in a folder that contains other folders.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Uses of DSL Patterns in Selenium
    By marulucky in forum Totally Off Topic
    Replies: 1
    Last Post: February 22nd, 2014, 04:33 AM
  2. Errors in Selenium
    By bhargavi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 5th, 2013, 10:57 AM
  3. another selenium question
    By bean in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 17th, 2013, 02:51 PM
  4. Java recursive calls
    By ksahakian21 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 1st, 2012, 01:50 PM
  5. Need Java code to be used in Selenium Script
    By anujbatta in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 25th, 2011, 10:50 AM