Python Forum
Selenium chromedriver and click action
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selenium chromedriver and click action
#1
Hello,

I am new to this and I am trying to click on a button with selenium and chromedriver, the button element is as below:

<button class="pagination-button pagination-direction pagination-direction--next" data-bind="click: goto.bind($data, 'next'), disable : isOnLastPage" data-test="pagination-next"> <span>Next</span> <div class="no-svg-chevron pagination-chevron pagination-chevron--forward pagination-chevron--next"> <svg> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#core-icon--chevron"></use> </svg> </div> </button>


I have tried with xpath and find element by class name, but click or submitting is not working.

Find below an extract of the different codes:
button = driver.find_element_by_class_name('pagination-direction--next')
button.click()
and the error:
Error:
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button class="pagination-button pagination-direction pagination-direction--next" data-bind="click: goto.bind($data, 'next'), disable : isOnLastPage" data-test="pagination-next">...</button> is not clickable at point (820, 853). Other element would receive the click: <button class="button" data-bind="click: closeMessage" data-test="close-cookie-popup-button">...</button>
if I replace click() by submit, I get the below error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Element was not in a form, so could not submit.

another test:
button = driver.find_element_by_xpath("//*[@id='l-container']/div[3]/div/div/div/div[3]/button")
button.click()
the error:
Error:
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button class="pagination-button pagination-direction pagination-direction--next" data-bind="click: goto.bind($data, 'next'), disable : isOnLastPage" data-test="pagination-next">...</button> is not clickable at point (820, 853). Other element would receive the click: <button class="button" data-bind="click: closeMessage" data-test="close-cookie-popup-button">...</button>
From this last error message it seems I need to find "button class="button" data-bind="click" but I can't find it in the source of the page, hence difficult to capture it as element with selenium and chromedriver

Any help would be appreciated.

Thanks,

Gilles95
Reply
#2
Its hard to say without looking at it myself...so i can only guess. Is there a popup occurring before your button click? Did you run it and see what is going on while its going through the steps? This is the only method to for sure verify the html is what you expect it to be.
Recommended Tutorials:
Reply
#3
Hello,

Thank you for replying.

There is no pop-up, it is a button to go to the next page on righmove search like here at the bottom.

To me yes, what is retrieved through selenium chrome driver is the same as what I see on the source page, but it is confusing to see "close-cookie-popup-button" in the error message.

Thanks for your help,

Gilles95
Reply
#4
(Feb-07-2018, 03:05 PM)Gilles95 Wrote: but it is confusing to see "close-cookie-popup-button" in the error message.
Do what the error message say and it should work.
Here a test that work for me.
from selenium import webdriver
from bs4 import BeautifulSoup
import time

# Activate Phantom and deactivate Chrome to not load browser
#browser = webdriver.PhantomJS()
browser = webdriver.Chrome()
web_url = 'Your url'
browser.get(web_url)
time.sleep(3)
close_cookie = browser.find_elements_by_css_selector('#cookiePolicy > div > button')
close_cookie[0].click()
time.sleep(3)
next_page = browser.find_elements_by_css_selector('.pagination-direction--next')
next_page[0].click()
Reply
#5
Excellent! Clap

Thanks for your help! It works now.

Gilles95
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium undetected Chromedriver Bot Laurin0000 1 3,918 Apr-13-2023, 09:20 PM
Last Post: Clixmaster
  Click on a button on web page using Selenium Pavel_47 7 4,507 Jan-05-2023, 04:20 AM
Last Post: ellapurnellrt
  enable flash using selenium chromedriver Fre3k 1 4,229 Nov-27-2020, 12:15 PM
Last Post: JellyCreeper6
  WebDriverException: 'chromedriver' executable needs to be in PATH pyzyx3qwerty 9 12,577 Jun-09-2020, 05:43 PM
Last Post: Yoriz
  Log In Button Won't Click - Python Selenium Webdriver samlee916 2 3,755 Jun-07-2020, 04:42 PM
Last Post: samlee916
  Selenium Chromedriver Automation Help lessthanthree 1 2,098 May-05-2020, 11:03 PM
Last Post: Larz60+
  Hyperlink Click is not working in Selenium webdriver rajeev1729 0 1,980 May-02-2020, 11:21 AM
Last Post: rajeev1729
  selenium click in iframe fails 3Pinter 6 4,972 Apr-29-2020, 12:59 PM
Last Post: Larz60+
  Contact form button click action Man_from_India 1 2,726 Feb-01-2020, 06:21 PM
Last Post: snippsat
  Python Selenium .click() Loads Error - Works Manually.- Events not Triggered NSearch 24 11,440 Aug-14-2019, 02:23 PM
Last Post: NSearch

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020