Unable to invoke click method on selected element












0















I need to click on a particular button in a Google MyBusiness page. The problem is that no click is happening.



Screenshot shows the button which is supposed to be clicked focused. The html of the element is:



<div role="button" class="U26fgb zg hx mZ r2" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;"
jsshadow="" jsname="BddwAf" aria-label="Remove" aria-disabled="false" tabindex="0">
<div class="Ci he" jsname="ksKsZd"></div>
<content class="gx"><span style="top: -12px"><svg xmlns="https://www.w3.org/2000/svg" width="24" height="24"
viewBox="0 0 24 24">
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path>
<path d="M0 0h24v24H0z" fill="none"></path>
</svg></span></content>
</div>


I have tried to do a wide search for similiar elements with the following selector:



hoursdiv = driver.find_elements_by_xpath('//div[@role = "button"]')
for el in hoursdiv:
print(el)
el.click


Output:



<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-5")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-6")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-7")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-8")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-9")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-10")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-11")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-12")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-13")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-14")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-15")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-16")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-17")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-18")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-19")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-20")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-21")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-22")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-23")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-24")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-25")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-26")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-27")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-28")>
<selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-29")>


But the element is not getting clicked.
The html of the section where these elements are displayed is uploaded here.



enter image description here










share|improve this question





























    0















    I need to click on a particular button in a Google MyBusiness page. The problem is that no click is happening.



    Screenshot shows the button which is supposed to be clicked focused. The html of the element is:



    <div role="button" class="U26fgb zg hx mZ r2" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;"
    jsshadow="" jsname="BddwAf" aria-label="Remove" aria-disabled="false" tabindex="0">
    <div class="Ci he" jsname="ksKsZd"></div>
    <content class="gx"><span style="top: -12px"><svg xmlns="https://www.w3.org/2000/svg" width="24" height="24"
    viewBox="0 0 24 24">
    <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path>
    <path d="M0 0h24v24H0z" fill="none"></path>
    </svg></span></content>
    </div>


    I have tried to do a wide search for similiar elements with the following selector:



    hoursdiv = driver.find_elements_by_xpath('//div[@role = "button"]')
    for el in hoursdiv:
    print(el)
    el.click


    Output:



    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-5")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-6")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-7")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-8")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-9")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-10")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-11")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-12")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-13")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-14")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-15")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-16")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-17")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-18")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-19")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-20")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-21")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-22")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-23")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-24")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-25")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-26")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-27")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-28")>
    <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-29")>


    But the element is not getting clicked.
    The html of the section where these elements are displayed is uploaded here.



    enter image description here










    share|improve this question



























      0












      0








      0








      I need to click on a particular button in a Google MyBusiness page. The problem is that no click is happening.



      Screenshot shows the button which is supposed to be clicked focused. The html of the element is:



      <div role="button" class="U26fgb zg hx mZ r2" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;"
      jsshadow="" jsname="BddwAf" aria-label="Remove" aria-disabled="false" tabindex="0">
      <div class="Ci he" jsname="ksKsZd"></div>
      <content class="gx"><span style="top: -12px"><svg xmlns="https://www.w3.org/2000/svg" width="24" height="24"
      viewBox="0 0 24 24">
      <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path>
      <path d="M0 0h24v24H0z" fill="none"></path>
      </svg></span></content>
      </div>


      I have tried to do a wide search for similiar elements with the following selector:



      hoursdiv = driver.find_elements_by_xpath('//div[@role = "button"]')
      for el in hoursdiv:
      print(el)
      el.click


      Output:



      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-5")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-6")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-7")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-8")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-9")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-10")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-11")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-12")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-13")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-14")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-15")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-16")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-17")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-18")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-19")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-20")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-21")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-22")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-23")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-24")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-25")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-26")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-27")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-28")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-29")>


      But the element is not getting clicked.
      The html of the section where these elements are displayed is uploaded here.



      enter image description here










      share|improve this question
















      I need to click on a particular button in a Google MyBusiness page. The problem is that no click is happening.



      Screenshot shows the button which is supposed to be clicked focused. The html of the element is:



      <div role="button" class="U26fgb zg hx mZ r2" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;"
      jsshadow="" jsname="BddwAf" aria-label="Remove" aria-disabled="false" tabindex="0">
      <div class="Ci he" jsname="ksKsZd"></div>
      <content class="gx"><span style="top: -12px"><svg xmlns="https://www.w3.org/2000/svg" width="24" height="24"
      viewBox="0 0 24 24">
      <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path>
      <path d="M0 0h24v24H0z" fill="none"></path>
      </svg></span></content>
      </div>


      I have tried to do a wide search for similiar elements with the following selector:



      hoursdiv = driver.find_elements_by_xpath('//div[@role = "button"]')
      for el in hoursdiv:
      print(el)
      el.click


      Output:



      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-5")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-6")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-7")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-8")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-9")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-10")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-11")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-12")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-13")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-14")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-15")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-16")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-17")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-18")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-19")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-20")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-21")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-22")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-23")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-24")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-25")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-26")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-27")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-28")>
      <selenium.webdriver.remote.webelement.WebElement (session="837341007f4b88350c3449e07e291d82", element="0.27450440234933726-29")>


      But the element is not getting clicked.
      The html of the section where these elements are displayed is uploaded here.



      enter image description here







      python selenium selenium-webdriver xpath css-selectors






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 14:46









      DebanjanB

      40.6k73878




      40.6k73878










      asked Nov 20 '18 at 12:47









      Joel G MathewJoel G Mathew

      2,02292745




      2,02292745
























          3 Answers
          3






          active

          oldest

          votes


















          1














          Try to wait until modal window with X buttons appeared and use more specific locator to select buttons:



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

          buttons = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, 'div[arial-label="Remove"] svg')))
          for button in buttons:
          button.click()





          share|improve this answer































            1














            The element which you are trying to click is a JavaScript enabled element, so you have to induce WebDriverwait for the element to be clickable and you can use either of the following solution:





            • Using CSS_SELECTOR:



              hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div[role='button'][aria-label='Remove']")))
              for el in hoursdiv:
              print(el)
              el.click()



            • Using XPATH:



              hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@role='button' and @aria-label='Remove']")))
              for el in hoursdiv:
              print(el)
              el.click()



            • 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































              0














              I assume wait is not your problem, it need two click, div and <content class="gx">






              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%2f53393323%2funable-to-invoke-click-method-on-selected-element%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









                1














                Try to wait until modal window with X buttons appeared and use more specific locator to select buttons:



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

                buttons = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, 'div[arial-label="Remove"] svg')))
                for button in buttons:
                button.click()





                share|improve this answer




























                  1














                  Try to wait until modal window with X buttons appeared and use more specific locator to select buttons:



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

                  buttons = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, 'div[arial-label="Remove"] svg')))
                  for button in buttons:
                  button.click()





                  share|improve this answer


























                    1












                    1








                    1







                    Try to wait until modal window with X buttons appeared and use more specific locator to select buttons:



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

                    buttons = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, 'div[arial-label="Remove"] svg')))
                    for button in buttons:
                    button.click()





                    share|improve this answer













                    Try to wait until modal window with X buttons appeared and use more specific locator to select buttons:



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

                    buttons = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, 'div[arial-label="Remove"] svg')))
                    for button in buttons:
                    button.click()






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 20 '18 at 13:05









                    AnderssonAndersson

                    38.5k103266




                    38.5k103266

























                        1














                        The element which you are trying to click is a JavaScript enabled element, so you have to induce WebDriverwait for the element to be clickable and you can use either of the following solution:





                        • Using CSS_SELECTOR:



                          hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div[role='button'][aria-label='Remove']")))
                          for el in hoursdiv:
                          print(el)
                          el.click()



                        • Using XPATH:



                          hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@role='button' and @aria-label='Remove']")))
                          for el in hoursdiv:
                          print(el)
                          el.click()



                        • 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














                          The element which you are trying to click is a JavaScript enabled element, so you have to induce WebDriverwait for the element to be clickable and you can use either of the following solution:





                          • Using CSS_SELECTOR:



                            hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div[role='button'][aria-label='Remove']")))
                            for el in hoursdiv:
                            print(el)
                            el.click()



                          • Using XPATH:



                            hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@role='button' and @aria-label='Remove']")))
                            for el in hoursdiv:
                            print(el)
                            el.click()



                          • 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












                            1








                            1







                            The element which you are trying to click is a JavaScript enabled element, so you have to induce WebDriverwait for the element to be clickable and you can use either of the following solution:





                            • Using CSS_SELECTOR:



                              hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div[role='button'][aria-label='Remove']")))
                              for el in hoursdiv:
                              print(el)
                              el.click()



                            • Using XPATH:



                              hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@role='button' and @aria-label='Remove']")))
                              for el in hoursdiv:
                              print(el)
                              el.click()



                            • 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 element which you are trying to click is a JavaScript enabled element, so you have to induce WebDriverwait for the element to be clickable and you can use either of the following solution:





                            • Using CSS_SELECTOR:



                              hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div[role='button'][aria-label='Remove']")))
                              for el in hoursdiv:
                              print(el)
                              el.click()



                            • Using XPATH:



                              hoursdiv = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@role='button' and @aria-label='Remove']")))
                              for el in hoursdiv:
                              print(el)
                              el.click()



                            • 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 Nov 20 '18 at 14:47









                            DebanjanBDebanjanB

                            40.6k73878




                            40.6k73878























                                0














                                I assume wait is not your problem, it need two click, div and <content class="gx">






                                share|improve this answer




























                                  0














                                  I assume wait is not your problem, it need two click, div and <content class="gx">






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    I assume wait is not your problem, it need two click, div and <content class="gx">






                                    share|improve this answer













                                    I assume wait is not your problem, it need two click, div and <content class="gx">







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 20 '18 at 13:33









                                    ewwinkewwink

                                    11.6k22238




                                    11.6k22238






























                                        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%2f53393323%2funable-to-invoke-click-method-on-selected-element%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

                                        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