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 26, 2020 in Selenium by Edureka
• 120 points
918 views
Do you get any error in the process?

1 answer to this question.

0 votes
The line of code seems to work for me
driver = webdriver.Chrome("C:/Users/Bryan Nelson/Desktop/chromedriver")
    
    song_name = input("Enter song name: ")
    song_name = song_name.title()
    song_name = song_name.replace(" ","-")
    song_request = driver.get("https://weedmp3.com/"+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")
answered Nov 20, 2020 by Nelson

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, 2020 in Selenium by Karan
• 19,610 points
8,340 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,150 points
15,837 views
0 votes
2 answers

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,500 points
13,673 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,142 views
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,910 points
7,221 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP