Clicking the hidden input Selenium in Python












1














I am trying to automate the login procedure with Selenium in Firefox with Python.



That's how a login button looks like in HTML:



<td>
<input name="cmd" value="lg" type="hidden">
<input src="ok.png" style="border-style: none;" type="image">
</td>


I have tried a following method:



loginButton = driver.find_elements_by_xpath("//input[@name='cmd' and @value='lg']")[0]
loginButton.click()


It returns the following exception with an empty message.




"selenium.common.exceptions.ElementNotInteractableException: Message: "




This method returns




"Message: Element is not visible"




loginButton = driver.find_element_by_name("cmd")
loginButton.send_keys(Keys.RETURN)


Could you please explain what I am missing?










share|improve this question
























  • The input is hidden, how is selenium then supposed to click it? Selenium emulates a user who would not be able to click it either
    – Metareven
    Nov 20 at 8:23












  • There is another input which is not hidden, but without the name and value, and it lays exactly on the hidden input. Sorry that I haven't mentioned it.
    – Andrey Mazur
    Nov 20 at 8:26










  • Then you should try clicking that one instead of the hidden one. Selenium will fail if it tries to click an element and something else is in the way
    – Metareven
    Nov 20 at 8:28










  • That's my problem, I cannot find the way how to get the access to an "input" which has only source, style and type. Webdriver has not function "driver.find_element_by_type("input")"
    – Andrey Mazur
    Nov 20 at 8:31








  • 1




    Why not just use a regular css selector? I use CSS-selectors for everything as I think the code becomes more uniform. You could also use the xpath-selector you wrote up there if you just remove the name and value stuff. I am not that good with xpath-selectors, but I assume it will select the first input on the page, just as a css-selector would
    – Metareven
    Nov 20 at 8:34
















1














I am trying to automate the login procedure with Selenium in Firefox with Python.



That's how a login button looks like in HTML:



<td>
<input name="cmd" value="lg" type="hidden">
<input src="ok.png" style="border-style: none;" type="image">
</td>


I have tried a following method:



loginButton = driver.find_elements_by_xpath("//input[@name='cmd' and @value='lg']")[0]
loginButton.click()


It returns the following exception with an empty message.




"selenium.common.exceptions.ElementNotInteractableException: Message: "




This method returns




"Message: Element is not visible"




loginButton = driver.find_element_by_name("cmd")
loginButton.send_keys(Keys.RETURN)


Could you please explain what I am missing?










share|improve this question
























  • The input is hidden, how is selenium then supposed to click it? Selenium emulates a user who would not be able to click it either
    – Metareven
    Nov 20 at 8:23












  • There is another input which is not hidden, but without the name and value, and it lays exactly on the hidden input. Sorry that I haven't mentioned it.
    – Andrey Mazur
    Nov 20 at 8:26










  • Then you should try clicking that one instead of the hidden one. Selenium will fail if it tries to click an element and something else is in the way
    – Metareven
    Nov 20 at 8:28










  • That's my problem, I cannot find the way how to get the access to an "input" which has only source, style and type. Webdriver has not function "driver.find_element_by_type("input")"
    – Andrey Mazur
    Nov 20 at 8:31








  • 1




    Why not just use a regular css selector? I use CSS-selectors for everything as I think the code becomes more uniform. You could also use the xpath-selector you wrote up there if you just remove the name and value stuff. I am not that good with xpath-selectors, but I assume it will select the first input on the page, just as a css-selector would
    – Metareven
    Nov 20 at 8:34














1












1








1







I am trying to automate the login procedure with Selenium in Firefox with Python.



That's how a login button looks like in HTML:



<td>
<input name="cmd" value="lg" type="hidden">
<input src="ok.png" style="border-style: none;" type="image">
</td>


I have tried a following method:



loginButton = driver.find_elements_by_xpath("//input[@name='cmd' and @value='lg']")[0]
loginButton.click()


It returns the following exception with an empty message.




"selenium.common.exceptions.ElementNotInteractableException: Message: "




This method returns




"Message: Element is not visible"




loginButton = driver.find_element_by_name("cmd")
loginButton.send_keys(Keys.RETURN)


Could you please explain what I am missing?










share|improve this question















I am trying to automate the login procedure with Selenium in Firefox with Python.



That's how a login button looks like in HTML:



<td>
<input name="cmd" value="lg" type="hidden">
<input src="ok.png" style="border-style: none;" type="image">
</td>


I have tried a following method:



loginButton = driver.find_elements_by_xpath("//input[@name='cmd' and @value='lg']")[0]
loginButton.click()


It returns the following exception with an empty message.




"selenium.common.exceptions.ElementNotInteractableException: Message: "




This method returns




"Message: Element is not visible"




loginButton = driver.find_element_by_name("cmd")
loginButton.send_keys(Keys.RETURN)


Could you please explain what I am missing?







python selenium firefox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 8:59









Andersson

37.2k103266




37.2k103266










asked Nov 20 at 8:21









Andrey Mazur

949




949












  • The input is hidden, how is selenium then supposed to click it? Selenium emulates a user who would not be able to click it either
    – Metareven
    Nov 20 at 8:23












  • There is another input which is not hidden, but without the name and value, and it lays exactly on the hidden input. Sorry that I haven't mentioned it.
    – Andrey Mazur
    Nov 20 at 8:26










  • Then you should try clicking that one instead of the hidden one. Selenium will fail if it tries to click an element and something else is in the way
    – Metareven
    Nov 20 at 8:28










  • That's my problem, I cannot find the way how to get the access to an "input" which has only source, style and type. Webdriver has not function "driver.find_element_by_type("input")"
    – Andrey Mazur
    Nov 20 at 8:31








  • 1




    Why not just use a regular css selector? I use CSS-selectors for everything as I think the code becomes more uniform. You could also use the xpath-selector you wrote up there if you just remove the name and value stuff. I am not that good with xpath-selectors, but I assume it will select the first input on the page, just as a css-selector would
    – Metareven
    Nov 20 at 8:34


















  • The input is hidden, how is selenium then supposed to click it? Selenium emulates a user who would not be able to click it either
    – Metareven
    Nov 20 at 8:23












  • There is another input which is not hidden, but without the name and value, and it lays exactly on the hidden input. Sorry that I haven't mentioned it.
    – Andrey Mazur
    Nov 20 at 8:26










  • Then you should try clicking that one instead of the hidden one. Selenium will fail if it tries to click an element and something else is in the way
    – Metareven
    Nov 20 at 8:28










  • That's my problem, I cannot find the way how to get the access to an "input" which has only source, style and type. Webdriver has not function "driver.find_element_by_type("input")"
    – Andrey Mazur
    Nov 20 at 8:31








  • 1




    Why not just use a regular css selector? I use CSS-selectors for everything as I think the code becomes more uniform. You could also use the xpath-selector you wrote up there if you just remove the name and value stuff. I am not that good with xpath-selectors, but I assume it will select the first input on the page, just as a css-selector would
    – Metareven
    Nov 20 at 8:34
















The input is hidden, how is selenium then supposed to click it? Selenium emulates a user who would not be able to click it either
– Metareven
Nov 20 at 8:23






The input is hidden, how is selenium then supposed to click it? Selenium emulates a user who would not be able to click it either
– Metareven
Nov 20 at 8:23














There is another input which is not hidden, but without the name and value, and it lays exactly on the hidden input. Sorry that I haven't mentioned it.
– Andrey Mazur
Nov 20 at 8:26




There is another input which is not hidden, but without the name and value, and it lays exactly on the hidden input. Sorry that I haven't mentioned it.
– Andrey Mazur
Nov 20 at 8:26












Then you should try clicking that one instead of the hidden one. Selenium will fail if it tries to click an element and something else is in the way
– Metareven
Nov 20 at 8:28




Then you should try clicking that one instead of the hidden one. Selenium will fail if it tries to click an element and something else is in the way
– Metareven
Nov 20 at 8:28












That's my problem, I cannot find the way how to get the access to an "input" which has only source, style and type. Webdriver has not function "driver.find_element_by_type("input")"
– Andrey Mazur
Nov 20 at 8:31






That's my problem, I cannot find the way how to get the access to an "input" which has only source, style and type. Webdriver has not function "driver.find_element_by_type("input")"
– Andrey Mazur
Nov 20 at 8:31






1




1




Why not just use a regular css selector? I use CSS-selectors for everything as I think the code becomes more uniform. You could also use the xpath-selector you wrote up there if you just remove the name and value stuff. I am not that good with xpath-selectors, but I assume it will select the first input on the page, just as a css-selector would
– Metareven
Nov 20 at 8:34




Why not just use a regular css selector? I use CSS-selectors for everything as I think the code becomes more uniform. You could also use the xpath-selector you wrote up there if you just remove the name and value stuff. I am not that good with xpath-selectors, but I assume it will select the first input on the page, just as a css-selector would
– Metareven
Nov 20 at 8:34












1 Answer
1






active

oldest

votes


















1














If you want to click on input next to hidden, try



loginButton = driver.find_element_by_xpath("//input[@src='ok.png']")
# loginButton = driver.find_element_by_xpath("//input[@name='cmd' and @value='lg']/following-sibling::input")
loginButton.click()





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


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388823%2fclicking-the-hidden-input-selenium-in-python%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    If you want to click on input next to hidden, try



    loginButton = driver.find_element_by_xpath("//input[@src='ok.png']")
    # loginButton = driver.find_element_by_xpath("//input[@name='cmd' and @value='lg']/following-sibling::input")
    loginButton.click()





    share|improve this answer


























      1














      If you want to click on input next to hidden, try



      loginButton = driver.find_element_by_xpath("//input[@src='ok.png']")
      # loginButton = driver.find_element_by_xpath("//input[@name='cmd' and @value='lg']/following-sibling::input")
      loginButton.click()





      share|improve this answer
























        1












        1








        1






        If you want to click on input next to hidden, try



        loginButton = driver.find_element_by_xpath("//input[@src='ok.png']")
        # loginButton = driver.find_element_by_xpath("//input[@name='cmd' and @value='lg']/following-sibling::input")
        loginButton.click()





        share|improve this answer












        If you want to click on input next to hidden, try



        loginButton = driver.find_element_by_xpath("//input[@src='ok.png']")
        # loginButton = driver.find_element_by_xpath("//input[@name='cmd' and @value='lg']/following-sibling::input")
        loginButton.click()






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 at 8:35









        Andersson

        37.2k103266




        37.2k103266






























            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.





            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%2f53388823%2fclicking-the-hidden-input-selenium-in-python%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

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]