How to locate the input within div












1














I got an issue reading XPath. Need some help/advise from experts.



Part of the HTML code:



<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->


I try to select the input in the div id="nav-typeahead-wormhole" using Xpath



My code is the following:



search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")


I got this error:



selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}









share|improve this question









New contributor




Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • try this xpath //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"] OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
    – Dev
    22 hours ago












  • thank you it's worked
    – Adam Smith
    7 hours ago
















1














I got an issue reading XPath. Need some help/advise from experts.



Part of the HTML code:



<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->


I try to select the input in the div id="nav-typeahead-wormhole" using Xpath



My code is the following:



search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")


I got this error:



selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}









share|improve this question









New contributor




Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • try this xpath //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"] OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
    – Dev
    22 hours ago












  • thank you it's worked
    – Adam Smith
    7 hours ago














1












1








1







I got an issue reading XPath. Need some help/advise from experts.



Part of the HTML code:



<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->


I try to select the input in the div id="nav-typeahead-wormhole" using Xpath



My code is the following:



search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")


I got this error:



selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}









share|improve this question









New contributor




Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I got an issue reading XPath. Need some help/advise from experts.



Part of the HTML code:



<div id="nav-typeahead-wormhole">
<div class="nav-search-typeahead">
<artdeco-typeahead-deprecated id="nav-search-artdeco-typeahead" class="search-typeahead-v2 ember-view">
<artdeco-typeahead-deprecated-input id="ember35" class="ember-view">
<!---->
<input role="combobox" autocomplete="off" spellcheck="false" aria-autocomplete="list" aria-expanded="false" placeholder="Recherche" type="text">
</artdeco-typeahead-deprecated-input>
<!---->


I try to select the input in the div id="nav-typeahead-wormhole" using Xpath



My code is the following:



search = browser.find_element_by_xpath("//div[@id='nav-typeahead-wormhole']/input[1]")


I got this error:



selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='nav-typeahead-wormhole']/input[1]"}






python-2.7 selenium-webdriver xpath css-selectors webdriverwait






share|improve this question









New contributor




Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 12 hours ago









DebanjanB

38.3k73475




38.3k73475






New contributor




Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 23 hours ago









Adam Smith

82




82




New contributor




Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Adam Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • try this xpath //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"] OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
    – Dev
    22 hours ago












  • thank you it's worked
    – Adam Smith
    7 hours ago


















  • try this xpath //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"] OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
    – Dev
    22 hours ago












  • thank you it's worked
    – Adam Smith
    7 hours ago
















try this xpath //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"] OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
– Dev
22 hours ago






try this xpath //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"] OR it may depends on your previous actions if it is visible/clickable on page, try adding wait before performing action
– Dev
22 hours ago














thank you it's worked
– Adam Smith
7 hours ago




thank you it's worked
– Adam Smith
7 hours ago












3 Answers
3






active

oldest

votes


















0














The desired <input> element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:





  • Using CSS_SELECTOR:



    search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))



  • Using XPATH:



    search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))



  • Note : You have to add the following imports :



    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC







share|improve this answer

















  • 1




    Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
    – Adam Smith
    6 hours ago



















1














The INPUT element isn't a child of the DIV you reference in your locator as is implied with the / operator. / is child (one level down), // is any descendant (one or more levels down). So your XPath should be:



//div[@id='nav-typeahead-wormhole']//input[1]


Other alternatives are:



//div[@id='nav-typeahead-wormhole']/div//input


or



//artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input


or



//artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input


or



//div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]





share|improve this answer























  • it works thank you !
    – Adam Smith
    6 hours ago



















0














Xpath is slow. Try using css selectors:



#nav-typeahead-wormhole input





share|improve this answer





















    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
    });


    }
    });






    Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53938057%2fhow-to-locate-the-input-within-div%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The desired <input> element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:





    • Using CSS_SELECTOR:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))



    • Using XPATH:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))



    • Note : You have to add the following imports :



      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support import expected_conditions as EC







    share|improve this answer

















    • 1




      Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
      – Adam Smith
      6 hours ago
















    0














    The desired <input> element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:





    • Using CSS_SELECTOR:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))



    • Using XPATH:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))



    • Note : You have to add the following imports :



      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support import expected_conditions as EC







    share|improve this answer

















    • 1




      Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
      – Adam Smith
      6 hours ago














    0












    0








    0






    The desired <input> element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:





    • Using CSS_SELECTOR:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))



    • Using XPATH:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))



    • Note : You have to add the following imports :



      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support import expected_conditions as EC







    share|improve this answer












    The desired <input> element is Ember.js based element so to identify the element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:





    • Using CSS_SELECTOR:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#nav-typeahead-wormhole input[placeholder='Recherche']")))



    • Using XPATH:



      search = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='nav-typeahead-wormhole']//input[@placeholder='Recherche']")))



    • Note : You have to add the following imports :



      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support import expected_conditions as EC








    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 12 hours ago









    DebanjanB

    38.3k73475




    38.3k73475








    • 1




      Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
      – Adam Smith
      6 hours ago














    • 1




      Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
      – Adam Smith
      6 hours ago








    1




    1




    Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
    – Adam Smith
    6 hours ago




    Thank you very muck ! That's excatly what I needed. The other anwers work as well for this part, but further I was stuck again and the only wait to get through is your method.
    – Adam Smith
    6 hours ago













    1














    The INPUT element isn't a child of the DIV you reference in your locator as is implied with the / operator. / is child (one level down), // is any descendant (one or more levels down). So your XPath should be:



    //div[@id='nav-typeahead-wormhole']//input[1]


    Other alternatives are:



    //div[@id='nav-typeahead-wormhole']/div//input


    or



    //artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input


    or



    //artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input


    or



    //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]





    share|improve this answer























    • it works thank you !
      – Adam Smith
      6 hours ago
















    1














    The INPUT element isn't a child of the DIV you reference in your locator as is implied with the / operator. / is child (one level down), // is any descendant (one or more levels down). So your XPath should be:



    //div[@id='nav-typeahead-wormhole']//input[1]


    Other alternatives are:



    //div[@id='nav-typeahead-wormhole']/div//input


    or



    //artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input


    or



    //artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input


    or



    //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]





    share|improve this answer























    • it works thank you !
      – Adam Smith
      6 hours ago














    1












    1








    1






    The INPUT element isn't a child of the DIV you reference in your locator as is implied with the / operator. / is child (one level down), // is any descendant (one or more levels down). So your XPath should be:



    //div[@id='nav-typeahead-wormhole']//input[1]


    Other alternatives are:



    //div[@id='nav-typeahead-wormhole']/div//input


    or



    //artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input


    or



    //artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input


    or



    //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]





    share|improve this answer














    The INPUT element isn't a child of the DIV you reference in your locator as is implied with the / operator. / is child (one level down), // is any descendant (one or more levels down). So your XPath should be:



    //div[@id='nav-typeahead-wormhole']//input[1]


    Other alternatives are:



    //div[@id='nav-typeahead-wormhole']/div//input


    or



    //artdeco-typeahead-deprecated[@id='nav-search-artdeco-typeahead']/artdeco-typeahead-deprecated-input/input


    or



    //artdeco-typeahead-deprecated/artdeco-typeahead-deprecated-input/input


    or



    //div[@id="nav-typeahead-wormhole"]//input[@placeholder="Recherche"]






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 20 hours ago









    JeffC

    12.1k41435




    12.1k41435










    answered 22 hours ago









    Max Kuznietsov

    564




    564












    • it works thank you !
      – Adam Smith
      6 hours ago


















    • it works thank you !
      – Adam Smith
      6 hours ago
















    it works thank you !
    – Adam Smith
    6 hours ago




    it works thank you !
    – Adam Smith
    6 hours ago











    0














    Xpath is slow. Try using css selectors:



    #nav-typeahead-wormhole input





    share|improve this answer


























      0














      Xpath is slow. Try using css selectors:



      #nav-typeahead-wormhole input





      share|improve this answer
























        0












        0








        0






        Xpath is slow. Try using css selectors:



        #nav-typeahead-wormhole input





        share|improve this answer












        Xpath is slow. Try using css selectors:



        #nav-typeahead-wormhole input






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 15 hours ago









        Infern0

        1,065213




        1,065213






















            Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.













            Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.












            Adam Smith is a new contributor. Be nice, and check out our Code of Conduct.
















            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53938057%2fhow-to-locate-the-input-within-div%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

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas