Search code examples
pythonseleniumhelium

ElementClickInterceptedException: Message: Element <select id because another element <iframe id="ba-widget-iframe" obscures it


I have a drop down single select combo box. I can get a reference to that drop down via a CSS selector.

<select class="single-option-selector no-select selector single-option-selector-100" data-option="option1" id="product-select-template--15646112383191__main-option-0">
    <option value="15.0cm">15.0cm</option>
    <option value="23.0cm">23.0cm</option>
    <option value="25.0cm">25.0cm</option>
</select>

I tried this

drop_down = [item.web_element for item in find_all(S(".single-option-selector-100"))][0]
select(drop_down, "23.0cm")

And i run into an exception.

    ElementClickInterceptedException: Message: Element 
<select id="product-select-template--15646112383191__main-option-0" 
class="single-option-selector no-select selector single-option-selector-100"> 
is not clickable at point (1012,655) because 
another element <iframe id="ba-widget-iframe" src="about:blank"> 
obscures it

Any ideas on how to get over this please ?

Hi Thanks a ton for all the the help and support Folks. I was able to resolve this with a lot of guidance from all of you been struggling on this for over 2 days. And here is a working code.

driver = start_firefox(headless=False)                                                                                                                                  
go_to(url)                                                                                                                                                                     
click(Button("Allow All"))  #Need this to accept all cookies                                                                                                   
frame = driver.find_element_by_xpath("//iframe[@id='ba-widget-iframe']")                                                        
driver.switch_to.frame(frame) #need to switch to iframe thingy.                                                                           
driver.find_element_by_css_selector("path").click()  #makes the iframe Modal go away phew finally      
driver.switch_to.parent_frame()  #Now iframe is finally done and dusted go back to main window and do actual meaningful work                               
drop_down = [                                                                                        
    item.web_element                                                                                 
    for item in find_all(                                                                            
        S(".single-option-selector.no-select.selector.single-option-selector-100")                     
    )                                                                                                
][0]                                                                         
select(drop_down, "23.0cm")

                                                                                              
                                                                              
                                                                                                             

                                                             

Thanks a ton for all the help :)


Solution

  • First you have to switch to the iframe;

    iframe = driver.find_element_by_xpath("//iframe[@id='ba-widget-iframe']")
    driver.switch_to.frame(iframe)
    drop_down = [item.web_element for item in find_all(S(".single-option-selector-100"))][0]
    select(drop_down, "23.0cm")