driver = webdriver.Chrome()
url = "https://onlineradiofm.in/stations/vividh-bharati"
driver.get(url)
radio_is_paused=True
while radio_is_paused:
time.sleep(30)
play_buttons = driver.find_elements(By.XPATH,'/html/body/div[2]/div/div/div/div[1]/div/div[1]/div/div[2]/div[1]/svg[1]/g/circle')
if len(play_buttons)>0:
print(len(play_buttons),' play buttons found')
else:
print('play button not found')
driver.quit()
I can see that web page gets opened in a browser and play button is visible .
I am not able to find out the reason that why I get 'play button not found' ?
I have also tried xpath //*[@id="play"]/g/circle , but got same result .
I got it working with https://github.com/seleniumbase/SeleniumBase (pip install seleniumbase
). I used ad_block_on=True
to block the page ads. Then I had to interact with the site first (clicked "h1"
). Finally, I used js_click
on "#play circle"
:
from seleniumbase import SB
with SB(ad_block_on=True) as sb:
sb.open("https://onlineradiofm.in/stations/vividh-bharati")
sb.click("h1")
sb.js_click("#play circle")
breakpoint()
Type c
and press Enter
to leave the breakpoint()
.