How to click the Spotify Play button with Python

Issue

Hay,
I try to click the Spotify Play button with Python
enter image description here
enter image description here

browser.find_element('<button class="btn btn-green false">PLAY</button>').click()

What is the correct code line to click required button?

Solution

You might need to update your code as

browser.find_element('xpath', '//button[.="PLAY"]').click()

Note that you should pass 2 arguments to find_element method:

  • locator strategy, e.g. xpath, css, etc
  • locator value

P.S. Also add browser.maximize_window() to the beginning of script to set browser fullscreen mode (DOM might differs due to different browser window size)

Answered By – JaSON

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published