I am trying to click on a button which looks like is present inside shadow root. Below is the image where I am trying to click:
When I trying to click the element above it, getting an error that element is not interactable.
Search any song on amazon prime music for doing it yourself.
Approach 1
song_result = driver.find_element(By.XPATH,"/html/body/div/music-app/div[4]/div/div/div/music-container/music-container[2]/div/music-shoveler")
song = song_result.find_element(By.TAG_NAME,"music-horizontal-item")
a = song.find_elements(By.TAG_NAME,"music-button")
a[1].click()
Approach 2
driver.find_element(By.XPATH,"/html/body/div/music-app/div[4]/div/div/div/music-container/music-container[2]/div/music-shoveler/music-horizontal-item[1]/music-button[2]//button").click()
Actually the order is like this:
<music-horizontal-item>
<music-button>
#shadowRoot
<button>
<music-button>
#shadowRoot
<button>This button I need to click
So I used this as per your suggestion
song_result = driver.find_element(By.XPATH,"/html/body/div/music-app/div[4]/div/div/div/music-container/music-container[2]/div/music-shoveler")
song = song_result.find_element(By.TAG_NAME,"music-horizontal-item")
a = song.find_elements(By.TAG_NAME,"music-button")
song_root = driver.execute_script("return arguments[0].shadowRoot",a[1])
song_root.find_element(By.TAG_NAME,"button").click()a
Still getting this error:
Message: element not interactable