Unable to locate the child iframe element which is within the parent iframe through Selenium in Java












1















So far, this is what I have: I've switched the frame to its parent frame then to the the frame I am unable to locate:



By frame = By.xpath("//iframe[@class='GenCss_style-Model']");

driver.switchTo().frame(driver.findElement(By.name("documentflowdesk")));
driver.switchTo().frame(driver.findElement(frame));


Since 'frame' element is not found, I get this error:




org.openqa.selenium.NoSuchElementException: Unable to locate element




HTML:



<iframe src="about:blank" name="documentflowdesk" class="gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame" id="documentflowdesk" style="position: absolute; left: 0px; top: 0px; visibility: visible; height: 100%;"></iframe>    
#documentflowdesk
<html style="overflow: hidden;">
<head>...</head>
<body style="margin: 0px;" class="dragdrop-dropTarget dragdrop-boundary">
<noscript>...</noscript>
<div style="position: absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
<div class="css-DeskStyleResources" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;">
<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; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
<iframe class="GenCss_style-Model" src="/model/?modelId=100&amp;docGroupId=164&amp;connectionPointId=73" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"></iframe>


The iframe I'm trying to locate is inside multiple div. Does it have to do anything with the error? Or is there a problem with how I find my element?










share|improve this question





























    1















    So far, this is what I have: I've switched the frame to its parent frame then to the the frame I am unable to locate:



    By frame = By.xpath("//iframe[@class='GenCss_style-Model']");

    driver.switchTo().frame(driver.findElement(By.name("documentflowdesk")));
    driver.switchTo().frame(driver.findElement(frame));


    Since 'frame' element is not found, I get this error:




    org.openqa.selenium.NoSuchElementException: Unable to locate element




    HTML:



    <iframe src="about:blank" name="documentflowdesk" class="gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame" id="documentflowdesk" style="position: absolute; left: 0px; top: 0px; visibility: visible; height: 100%;"></iframe>    
    #documentflowdesk
    <html style="overflow: hidden;">
    <head>...</head>
    <body style="margin: 0px;" class="dragdrop-dropTarget dragdrop-boundary">
    <noscript>...</noscript>
    <div style="position: absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
    <div class="css-DeskStyleResources" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;">
    <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; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
    <iframe class="GenCss_style-Model" src="/model/?modelId=100&amp;docGroupId=164&amp;connectionPointId=73" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"></iframe>


    The iframe I'm trying to locate is inside multiple div. Does it have to do anything with the error? Or is there a problem with how I find my element?










    share|improve this question



























      1












      1








      1








      So far, this is what I have: I've switched the frame to its parent frame then to the the frame I am unable to locate:



      By frame = By.xpath("//iframe[@class='GenCss_style-Model']");

      driver.switchTo().frame(driver.findElement(By.name("documentflowdesk")));
      driver.switchTo().frame(driver.findElement(frame));


      Since 'frame' element is not found, I get this error:




      org.openqa.selenium.NoSuchElementException: Unable to locate element




      HTML:



      <iframe src="about:blank" name="documentflowdesk" class="gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame" id="documentflowdesk" style="position: absolute; left: 0px; top: 0px; visibility: visible; height: 100%;"></iframe>    
      #documentflowdesk
      <html style="overflow: hidden;">
      <head>...</head>
      <body style="margin: 0px;" class="dragdrop-dropTarget dragdrop-boundary">
      <noscript>...</noscript>
      <div style="position: absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
      <div class="css-DeskStyleResources" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;">
      <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; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
      <iframe class="GenCss_style-Model" src="/model/?modelId=100&amp;docGroupId=164&amp;connectionPointId=73" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"></iframe>


      The iframe I'm trying to locate is inside multiple div. Does it have to do anything with the error? Or is there a problem with how I find my element?










      share|improve this question
















      So far, this is what I have: I've switched the frame to its parent frame then to the the frame I am unable to locate:



      By frame = By.xpath("//iframe[@class='GenCss_style-Model']");

      driver.switchTo().frame(driver.findElement(By.name("documentflowdesk")));
      driver.switchTo().frame(driver.findElement(frame));


      Since 'frame' element is not found, I get this error:




      org.openqa.selenium.NoSuchElementException: Unable to locate element




      HTML:



      <iframe src="about:blank" name="documentflowdesk" class="gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame" id="documentflowdesk" style="position: absolute; left: 0px; top: 0px; visibility: visible; height: 100%;"></iframe>    
      #documentflowdesk
      <html style="overflow: hidden;">
      <head>...</head>
      <body style="margin: 0px;" class="dragdrop-dropTarget dragdrop-boundary">
      <noscript>...</noscript>
      <div style="position: absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
      <div class="css-DeskStyleResources" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;">
      <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; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;">
      <iframe class="GenCss_style-Model" src="/model/?modelId=100&amp;docGroupId=164&amp;connectionPointId=73" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;"></iframe>


      The iframe I'm trying to locate is inside multiple div. Does it have to do anything with the error? Or is there a problem with how I find my element?







      java selenium selenium-webdriver iframe webdriverwait






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 11:32









      DebanjanB

      42.9k94283




      42.9k94283










      asked Nov 6 '18 at 4:54









      CharleneCharlene

      82




      82
























          2 Answers
          2






          active

          oldest

          votes


















          1














          As per the HTML once you are on the parent frame you have to:




          • Induce WebDriverWait for the parent frame to be available and switch to it.

          • Induce WebDriverWait for the child frame to be available and switch to it.


          • You can use the following solution:



            new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame' and @id='documentflowdesk']")));
            new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='GenCss_style-Model' and contains(@src,'connectionPointId')]")));



          Here you can find a relevant discussion on Ways to deal with #document under iframe






          share|improve this answer

































            1














            Please try below code:



            driver.switchTo().frame(driver.findelement(By.xpath(//iframe[@name='documentflowdesk']);

            Thread.sleep(5000);

            driver.switchTo().frame(driver.findelement(By.xpath(//ifame[@class='GenCss_style-Model']);





            share|improve this answer





















            • 1





              Thread.sleep is bad practice.!

              – Code_10
              Nov 6 '18 at 6:22











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53165931%2funable-to-locate-the-child-iframe-element-which-is-within-the-parent-iframe-thro%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            As per the HTML once you are on the parent frame you have to:




            • Induce WebDriverWait for the parent frame to be available and switch to it.

            • Induce WebDriverWait for the child frame to be available and switch to it.


            • You can use the following solution:



              new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame' and @id='documentflowdesk']")));
              new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='GenCss_style-Model' and contains(@src,'connectionPointId')]")));



            Here you can find a relevant discussion on Ways to deal with #document under iframe






            share|improve this answer






























              1














              As per the HTML once you are on the parent frame you have to:




              • Induce WebDriverWait for the parent frame to be available and switch to it.

              • Induce WebDriverWait for the child frame to be available and switch to it.


              • You can use the following solution:



                new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame' and @id='documentflowdesk']")));
                new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='GenCss_style-Model' and contains(@src,'connectionPointId')]")));



              Here you can find a relevant discussion on Ways to deal with #document under iframe






              share|improve this answer




























                1












                1








                1







                As per the HTML once you are on the parent frame you have to:




                • Induce WebDriverWait for the parent frame to be available and switch to it.

                • Induce WebDriverWait for the child frame to be available and switch to it.


                • You can use the following solution:



                  new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame' and @id='documentflowdesk']")));
                  new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='GenCss_style-Model' and contains(@src,'connectionPointId')]")));



                Here you can find a relevant discussion on Ways to deal with #document under iframe






                share|improve this answer















                As per the HTML once you are on the parent frame you have to:




                • Induce WebDriverWait for the parent frame to be available and switch to it.

                • Induce WebDriverWait for the child frame to be available and switch to it.


                • You can use the following solution:



                  new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='gwt-Frame-NavigationComponentViewImplResourcesapplicationFrame' and @id='documentflowdesk']")));
                  new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@class='GenCss_style-Model' and contains(@src,'connectionPointId')]")));



                Here you can find a relevant discussion on Ways to deal with #document under iframe







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 24 '18 at 7:08

























                answered Nov 6 '18 at 6:15









                DebanjanBDebanjanB

                42.9k94283




                42.9k94283

























                    1














                    Please try below code:



                    driver.switchTo().frame(driver.findelement(By.xpath(//iframe[@name='documentflowdesk']);

                    Thread.sleep(5000);

                    driver.switchTo().frame(driver.findelement(By.xpath(//ifame[@class='GenCss_style-Model']);





                    share|improve this answer





















                    • 1





                      Thread.sleep is bad practice.!

                      – Code_10
                      Nov 6 '18 at 6:22
















                    1














                    Please try below code:



                    driver.switchTo().frame(driver.findelement(By.xpath(//iframe[@name='documentflowdesk']);

                    Thread.sleep(5000);

                    driver.switchTo().frame(driver.findelement(By.xpath(//ifame[@class='GenCss_style-Model']);





                    share|improve this answer





















                    • 1





                      Thread.sleep is bad practice.!

                      – Code_10
                      Nov 6 '18 at 6:22














                    1












                    1








                    1







                    Please try below code:



                    driver.switchTo().frame(driver.findelement(By.xpath(//iframe[@name='documentflowdesk']);

                    Thread.sleep(5000);

                    driver.switchTo().frame(driver.findelement(By.xpath(//ifame[@class='GenCss_style-Model']);





                    share|improve this answer















                    Please try below code:



                    driver.switchTo().frame(driver.findelement(By.xpath(//iframe[@name='documentflowdesk']);

                    Thread.sleep(5000);

                    driver.switchTo().frame(driver.findelement(By.xpath(//ifame[@class='GenCss_style-Model']);






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 6 '18 at 6:12









                    DebanjanB

                    42.9k94283




                    42.9k94283










                    answered Nov 6 '18 at 5:54









                    Kamil KhanKamil Khan

                    111




                    111








                    • 1





                      Thread.sleep is bad practice.!

                      – Code_10
                      Nov 6 '18 at 6:22














                    • 1





                      Thread.sleep is bad practice.!

                      – Code_10
                      Nov 6 '18 at 6:22








                    1




                    1





                    Thread.sleep is bad practice.!

                    – Code_10
                    Nov 6 '18 at 6:22





                    Thread.sleep is bad practice.!

                    – Code_10
                    Nov 6 '18 at 6:22


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53165931%2funable-to-locate-the-child-iframe-element-which-is-within-the-parent-iframe-thro%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Create new schema in PostgreSQL using DBeaver

                    Deepest pit of an array with Javascript: test on Codility

                    Costa Masnaga