AttributeError: 'list' object has no attribute 'click' - Selenium Webdriver using Python [duplicate]












1
















This question already has an answer here:




  • 'list' object has no attribute 'get_attribute' while iterating through WebElements

    3 answers




I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?



Traceback (most recent call last):
File "C:/Users/Sagnik/Desktop/pp.py", line 13, in <module>
user.click()
AttributeError: 'list' object has no attribute 'click'



Below is my code:



from selenium import webdriver
driver = webdriver.Firefox()
driver.get('url')

input("Anything after scanning QR code")

names = ["ABC", "DEF"]

for name in names:
print(name)
user = driver.find_elements_by_xpath('//span[@title = "{0}"]'.format(name))

user.click()


I think I am missing something. please suggest me










share|improve this question













marked as duplicate by DebanjanB selenium
Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 5 at 10:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    1
















    This question already has an answer here:




    • 'list' object has no attribute 'get_attribute' while iterating through WebElements

      3 answers




    I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?



    Traceback (most recent call last):
    File "C:/Users/Sagnik/Desktop/pp.py", line 13, in <module>
    user.click()
    AttributeError: 'list' object has no attribute 'click'



    Below is my code:



    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get('url')

    input("Anything after scanning QR code")

    names = ["ABC", "DEF"]

    for name in names:
    print(name)
    user = driver.find_elements_by_xpath('//span[@title = "{0}"]'.format(name))

    user.click()


    I think I am missing something. please suggest me










    share|improve this question













    marked as duplicate by DebanjanB selenium
    Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Jan 5 at 10:46


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      1












      1








      1









      This question already has an answer here:




      • 'list' object has no attribute 'get_attribute' while iterating through WebElements

        3 answers




      I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?



      Traceback (most recent call last):
      File "C:/Users/Sagnik/Desktop/pp.py", line 13, in <module>
      user.click()
      AttributeError: 'list' object has no attribute 'click'



      Below is my code:



      from selenium import webdriver
      driver = webdriver.Firefox()
      driver.get('url')

      input("Anything after scanning QR code")

      names = ["ABC", "DEF"]

      for name in names:
      print(name)
      user = driver.find_elements_by_xpath('//span[@title = "{0}"]'.format(name))

      user.click()


      I think I am missing something. please suggest me










      share|improve this question















      This question already has an answer here:




      • 'list' object has no attribute 'get_attribute' while iterating through WebElements

        3 answers




      I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?



      Traceback (most recent call last):
      File "C:/Users/Sagnik/Desktop/pp.py", line 13, in <module>
      user.click()
      AttributeError: 'list' object has no attribute 'click'



      Below is my code:



      from selenium import webdriver
      driver = webdriver.Firefox()
      driver.get('url')

      input("Anything after scanning QR code")

      names = ["ABC", "DEF"]

      for name in names:
      print(name)
      user = driver.find_elements_by_xpath('//span[@title = "{0}"]'.format(name))

      user.click()


      I think I am missing something. please suggest me





      This question already has an answer here:




      • 'list' object has no attribute 'get_attribute' while iterating through WebElements

        3 answers








      python selenium selenium-webdriver webdriver attributeerror






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 3:22









      Sagnik ChattopadhyayaSagnik Chattopadhyaya

      63




      63




      marked as duplicate by DebanjanB selenium
      Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Jan 5 at 10:46


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by DebanjanB selenium
      Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Jan 5 at 10:46


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          2 Answers
          2






          active

          oldest

          votes


















          3














          find_elements_by_xpath()


          returns a list of results. Maybe you want find_element_by_xpath instead?






          share|improve this answer































            0














            Use @DanielleM.'s solution if user is a list with only one element, otherwise do:



            for i in user:
            i.click()


            Instead of:



            user.click()





            share|improve this answer






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              find_elements_by_xpath()


              returns a list of results. Maybe you want find_element_by_xpath instead?






              share|improve this answer




























                3














                find_elements_by_xpath()


                returns a list of results. Maybe you want find_element_by_xpath instead?






                share|improve this answer


























                  3












                  3








                  3







                  find_elements_by_xpath()


                  returns a list of results. Maybe you want find_element_by_xpath instead?






                  share|improve this answer













                  find_elements_by_xpath()


                  returns a list of results. Maybe you want find_element_by_xpath instead?







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 2 at 3:28









                  Danielle M.Danielle M.

                  1,9251523




                  1,9251523

























                      0














                      Use @DanielleM.'s solution if user is a list with only one element, otherwise do:



                      for i in user:
                      i.click()


                      Instead of:



                      user.click()





                      share|improve this answer




























                        0














                        Use @DanielleM.'s solution if user is a list with only one element, otherwise do:



                        for i in user:
                        i.click()


                        Instead of:



                        user.click()





                        share|improve this answer


























                          0












                          0








                          0







                          Use @DanielleM.'s solution if user is a list with only one element, otherwise do:



                          for i in user:
                          i.click()


                          Instead of:



                          user.click()





                          share|improve this answer













                          Use @DanielleM.'s solution if user is a list with only one element, otherwise do:



                          for i in user:
                          i.click()


                          Instead of:



                          user.click()






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 2 at 3:33









                          U9-ForwardU9-Forward

                          16.7k51643




                          16.7k51643















                              Popular posts from this blog

                              MongoDB - Not Authorized To Execute Command

                              How to fix TextFormField cause rebuild widget in Flutter

                              Npm cannot find a required file even through it is in the searched directory