Helium driver.execute_script but what should be the first arguement?

114 views Asked by At

I have the below HTML fragment. The fragment is a drop down.

<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>

When i try this in helium using python

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

I get ElementClickInterceptedException.

So i am thinking of executing the javascript behind the drop down box.

So what i am trying is

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

                                                                         
                                                                               
res = drop_down.find_elements_by_tag_name("option")[1]

But i am confused what should be the script that should be executed ?

driver.execute_script(<<what should be here>> , res)


                         
1

There are 1 answers

0
pguardiario On

I think you just want:

document.querySelector('select[data-option="option1"]').value="23.0cm"

but if it's vue/react you might need to click it