There is a site of this type

enter image description here

At the top you can see the buttons that I can’t click on.

Here is the code itself

from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome() driver.get('https://coinmarketcap.com/currencies/bitcoin/#charts') driver.find_element_by_class_name('highcharts-button highcharts-button-normal').click() driver.save_screenshot('screencoin.jpg') driver.quit() 

Here is the code for this button taken from the site.

 <g class="highcharts-button highcharts-button-normal" style="cursor:pointer;" transform="translate(122,0)"><rect fill="#f7f7f7" class=" highcharts-button-box" x="0" y="0" width="32" height="22" rx="2" ry="2"></rect><text x="8.4296875" style="font-weight:normal;color:#333333;fill:#333333;" y="14">1d</text></g> 

Tried to substitute another class.

 driver.find_element_by_class_name('highcharts-button-box').click() 

As a result, I get these errors

 Traceback (most recent call last): File "crypto.py", line 6, in <module> driver.find_element_by_class_name('highcharts-button highcharts-button-normal').click() File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 555, in find_element_by_class_name return self.find_element(by=By.CLASS_NAME, value=name) File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 955, in find_element 'value': value})['value'] File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute self.error_handler.check_response(response) File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Compound class names not permitted (Session info: chrome=63.0.3239.132) (Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.12.6 x86_64 

and one more to another attempt

 Traceback (most recent call last): File "crypto.py", line 6, in <module> driver.find_element_by_class_name(' highcharts-button-box').click() File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click self._execute(Command.CLICK_ELEMENT) File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 628, in _execute return self._parent.execute(command, params) File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute self.error_handler.check_response(response) File "/Users/milkiweed/Desktop/VIRTUAL_ENV/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Element <rect fill="#f7f7f7" class=" highcharts-button-box" x="0" y="0" width="32" height="22" rx="2" ry="2"></rect> is not clickable at point (153, 64). Other element would receive the click: <text x="8.4296875" style="font-weight:normal;color:#333333;fill:#333333;" y="14">...</text> (Session info: chrome=63.0.3239.132) (Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.12.6 x86_64) 

It is required to press this button. enter image description here

    2 answers 2

    Your first error, Compound class names not permitted says that only elements with a single class can be searched for by the find_element_by_class_name() method. You have two: class="highcharts-button highcharts-button-normal" . To search for such elements, use the search by css selectors or xpath.

    The second error Element <...> is not clickable at point (153, 64). Other element would receive the click Element <...> is not clickable at point (153, 64). Other element would receive the click indicate that the Element <...> is not clickable at point (153, 64). Other element would receive the click blocked by another. On the overlapped elements, the chrome driver is not allowed to click.

    Try clicking on the text element. I will give an example, but I cannot vouch that my xpath will always work, since I need to see the entire DOM in order to make the best one.

     driver.find_element_by_xpath( '//g[@class="highcharts-button highcharts-button-normal"]/text[text()="1d"]' ).click() 

      Firstly, I would suggest to make an assert that the button is and is in a clickable state, and secondly, you should never look for a class, unless this class is not alone, specifically for this element. It is necessary to search by the most unique parameters. In this case, I would pay attention to the text. As a last resort, in a separate variable, specify the x-path (or css-selector, if you like it more) of the button and already through it look for it and click.