Skip to content Skip to sidebar Skip to footer

Open An Accordion With Selenium In Python

I'm trying to open an accordion link with selenium in python. The element looks like this when closed:

Solution 1:

Basically, document.getElementsByClassName('crm-accordion-body') returns a Node List. So we have to use index to get hold of the intended Node as follows :

document.getElementsByClassName('btn-pageMenu')[0].style.display

So as we are trying to change the style="display: none;" for the first node, try the following line of code :

driver.execute_script("document.getElementsByClassName('crm-accordion-body')[0].style.display='block';")

Post a Comment for "Open An Accordion With Selenium In Python"