whenever it downloads chrome shows a notification of allow and block. I tried saving the changes to always allow but when i run the code its the same. Can I automate or save changes permanently.

0 votes
from selenium import webdriver
from bs4 import BeautifulSoup
import requests

def music():
    
    driver = webdriver.Chrome("C:/Users/Akshay Dileep/Desktop/chromedriver")
    
    song_name = input("Enter song name: ")
    song_name = song_name.title()
    song_name = song_name.replace(" ","-")
    song_request = driver.get("https://mp3paw.com/mp3-download/"+song_name)
    song_query = driver.find_elements_by_class_name("mp3")
    song_details = driver.find_elements_by_tag_name("h3")
    song_duration = driver.find_elements_by_class_name("mp3-duration")
    
    play_button_x_path = ["//*[@id='mp3List']/div[1]/div[3]/ul/li[1]/div",
                          "//*[@id='mp3List']/div[2]/div[3]/ul/li[1]/div",
                          "//*[@id='mp3List']/div[3]/div[3]/ul/li[1]/div",
                          "//*[@id='mp3List']/div[4]/div[3]/ul/li[1]/div",
                          "//*[@id='mp3List']/div[5]/div[3]/ul/li[1]/div"]
    
    download_button_x_path = ["//*[@id='mp3List']/div[1]/div[3]/ul/li[3]/div",
                              "//*[@id='mp3List']/div[2]/div[3]/ul/li[3]/div",
                              "//*[@id='mp3List']/div[3]/div[3]/ul/li[3]/div",
                              "//*[@id='mp3List']/div[4]/div[3]/ul/li[3]/div",
                              "//*[@id='mp3List']/div[5]/div[3]/ul/li[3]/div"]
    if song_query is None:
        print("Your requested song isn't available")
    else:
        for i in range(5):
            print(str(i + 1)+".> ",song_details[i].text)
            print("duration = ",song_duration[i].text,"\n")
        index = int(input("Enter the index number of song you would like to download: "))
        index = index - 1
        choice = input("would you like to play the song or download the song: ")
        if choice == "play":
            driver.find_element_by_xpath(play_button_x_path[index]).click()
        elif choice == "download":
            driver.find_element_by_xpath(download_button_x_path[index]).click()
            handle = driver.window_handles
            driver.switch_to.window(handle[1])
            request = requests.get(driver.current_url)
            html_page = BeautifulSoup(request.content,"html.parser")
            song_quality = html_page.findAll("div", {"class":"rate"})
            song_size = html_page.findAll("div", {"class":"foot"})
            print("Available qualities are: ")
            for i in range(6):
                print(str(i + 1)+".>",song_quality[i].text)
                print("size:",song_size[i + 1].text,"\n")
            quality_choice = int(input("Which one would you like to download: "))
            if quality_choice == 1:
                driver.find_element_by_class_name("btr-320").click()
            elif quality_choice == 2:
                driver.find_element_by_class_name("btr-256").click()
            elif quality_choice == 3:
                driver.find_element_by_class_name("btr-192").click()
            elif quality_choice == 4:
                driver.find_element_by_class_name("btr-128").click()
            elif quality_choice == 5:
                driver.find_element_by_class_name("btr-64").click()
            elif quality_choice == 6:
                driver.find_element_by_class_name("btr-32").click()
            print("Your song will be downloaded")
music()
Apr 25 in Selenium by Edureka
• 120 points
88 views
Do you get any error in the process?

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Selenium

0 votes
2 answers
+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this https://www.edureka.co/community/47160/automate-purchase-adding-book-cart-flipkart-using-selenium? It deals with a similar ...READ MORE

answered Jan 13 in Selenium by Karan
• 10,080 points
2,044 views
+1 vote
2 answers
+1 vote
1 answer
0 votes
1 answer

How to write a code for combo box and how can i select a country from country dropdown?

https://stackoverflow.com/questions/40017443/how-to-perform-dropdow ...READ MORE

answered May 8 in Selenium by vaibhav
449 views
0 votes
1 answer

Is it possible to automate the captcha and bar-code reader using Selenium?

Hey Ruhi, it’s not possible to automate ...READ MORE

answered Jun 4, 2019 in Selenium by Umang
355 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,070 points
1,594 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
2,641 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,870 points
2,077 views