0

I would like to have Selenium navigate thorught the items of a navbar of this page, then retrieve its contents and pass them to beatifulsoup.

My code works fine for the first page, after which I get the following error:

ElementClickInterceptedException: Message: element click intercepted: Element <a href="https://www.rollingstone.com/music/music-lists/500-greatest-songs-of-all-time-151127/smokey-robinson-and-the-miracles-shop-around-71184" style="color: rgb(211, 37, 49); padding: 4px 8px;">...</a> is not clickable at point (77, 73). Other element would receive the click: <div class="fc-dialog-overlay"></div>

Previous answers have not helped. Here is my code. I would truly appreciate any help.

webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--incognito')
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)

target_page = 'https://www.rollingstone.com/music/music-lists/500-greatest-songs-of-all-time-151127/'

driver.get(target_page)
header = driver.find_element_by_id('pmc-gallery-list-nav-bar-render')
items = header.find_elements_by_tag_name('a')

songs = []

for item in items:    
    driver.maximize_window()
    time.sleep(5)
    item.click()
    page_source = driver.page_source
    soup = BeautifulSoup(page_source)
    song_all = soup.find_all('h2', {'class':'c-gallery-vertical-album__title'})
    for song in song_all:
        songs.append(strip_extra_chars(song.get_text()))

driver.quit()

1 Answers1

2

Let's comment options.add_argument('--headless') and see how program runs. You need to identify which element overlap your link. For example, I tried to run your code and this dialog apears:

popup window

In this case, to disable notification you can add:

prefs = {"profile.default_content_setting_values.notifications": 2}
options.add_experimental_option("prefs", prefs)

But this dialog doesn't match .fc-dialog-overlay locator so probably your problem with another element. You need to find it.

Another solution, you can click using js driver.execute_script()