Skip to content

Instantly share code, notes, and snippets.

@kevsersrca
Created December 4, 2019 08:59
Show Gist options
  • Save kevsersrca/7a75673545cae3db0488eb06084685d5 to your computer and use it in GitHub Desktop.
Save kevsersrca/7a75673545cae3db0488eb06084685d5 to your computer and use it in GitHub Desktop.
selenium test
def currently_playing(self):
'''
Returns the record for the currently playing track,
or None if nothing is playing
'''
try:
if self.is_playing():
title = self.browser.find_element_by_class_name('title').text
album_detail = self.browser.find_element_by_css_selector('.detail-album > a')
album_title = album_detail.text
album_url = album_detail.get_attribute('href').split('?')[0]
artist_detail = self.browser.find_element_by_css_selector('.detail-artist > a')
artist = artist_detail.text
artist_url = artist_detail.get_attribute('href').split('?')[0]
return TrackRec(title, artist, artist_url, album_title, album_url, ctime())
except Exception as e:
print('there was an error: {}'.format(e))
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment