Learn selenium Automation with Spotify | Part 1 | Python | AI Assistant

Part - 1: Learn Automation with Spotify
Basic to Advance

Why Automation?

To add advanced features to our Assistant, we use automation, which can be deployed to many different websites, so we're using Spotify as an example; you can use other websites for testing. The video shows an example of Spotify automation. Similar concepts are used in all sorts of automation. Spotify API was intentionally not used for automation because I wanted to use a concept instead. With the help of APIs, you can also implement this! Explore and learn!

Remember to try to experiment with other platforms, we will see much more automation in the future videos, So stay tuned till then.

What is Selenium Automation?

We can say that Selenium is an open source testing framework that is required for automation or that it is one of a number of automation tools/frameworks for automating applications. The test cases are run multiple times across browsers


How easy is Selenium automation?
Selenium isn't really difficult to learn for it to be learned quickly, however, it is important to have a good disciple and a strategic road map. It is therefore important to focus on four things to gain a better understanding and familiarity with Selenium testing: Java, Selenium Webdriver, TestNG, and Frameworks.

The role of Selenium automation in AI assistant!
As we learn Selenium automation for automating web tools, you will see how we use automation on websites as well as Spotify automation.
In the same way, we can use web tools that are efficient and run in the background, Giving your system direct output


Which is better Xpath OR CSS_SELECTOR?


Download Chrome driver :
To download the chrome driver, first, check which version of Chrome you are using, and then you need to download the chrome driver for that version


chrome://settings/help

For example, my chrome version is 98 so simply download any chrome driver with the specific version


Facing Error?
The error looks like this because you downloaded the wrong file.
Be sure to check the browser version before downloading.!



By Using Xpath

You can use Inspect button or the Extension to find the Xpath of the element

Chrome-extensions  :

  1. import config #config.py has username and password
  2. from selenium import webdriver
  3. from time import sleep
  4. from selenium.webdriver.common.by import By

  5. options = webdriver.ChromeOptions()
  6. options.headless = True # if false all the stuff will load in backend
  7. driver = webdriver.Chrome('') # driver path cheak your current browser first than download respectively >>
  8. # chrome://settings/help

  9. url = 'https://accounts.spotify.com/en/login?continue=https%3A%2F%2Fopen.spotify.com%2F'


  10. def login(Email, Password):
  11. driver.get(url)
  12. driver.maximize_window()

  13. # WITH XPATH

  14. driver.find_element(By.XPATH, '//*[@id="login-username"]').send_keys(Email)
  15. driver.find_element(By.XPATH, '//*[@id="login-password"]').send_keys(Password)
  16. driver.find_element(By.XPATH, '//*[@id="login-button"]/div[1]/p').click()

  17. sleep(2) # we wait for page to load /-OR else we see !ERROR(only some times)


  18. login(config.username, config.password)

By Using CSS_SELECTOR

You can use Inspect button or the Extension to find the CSS_SELECTOR of the element

Chrome-extensions  :

  1. import config #config.py has username and password
  2. from selenium import webdriver
  3. from time import sleep
  4. from selenium.webdriver.common.by import By

  5. options = webdriver.ChromeOptions()
  6. options.headless = True # if false all the stuff will load in backend
  7. driver = webdriver.Chrome('') # driver path cheak your current browser first than download respectively >>
  8. # chrome://settings/help

  9. url = 'https://accounts.spotify.com/en/login?continue=https%3A%2F%2Fopen.spotify.com%2F'


  10. def login(Email, Password):
  11. driver.get(url)
  12. driver.maximize_window()

  13. # WITH XPATH

  14. driver.find_element(By.CSS_SELECTOR, "#login-username").send_keys(Email)
  15. driver.find_element(By.CSS_SELECTOR, "#login-password").send_keys(Password)
  16. driver.find_element(By.CSS_SELECTOR, "button[id='login-button'] div:nth-child(1)").click()

  17. sleep(2) # we wait for page to load /-OR else we see !ERROR(only some times)


  18. login(config.username, config.password)

 In Part - 6 we will see more topics 

1 Comments

If you have any doubts, please let me know

Previous Post Next Post