'Which expected_conditions to use?

I have this list on a website using Python's Selenium.

enter image description here

Clicking an item opens a sublist where you can click multiple buttons. I click these buttons with JavaScript so that the sublist never opens. This method is faster.

...
driver.execute_script(button)

My question is which expected_conditions should I use to wait for the buttons to appear in the DOM so that I can select it with JavaScript?

expected_conditions.element_to_be_clickable (what I use all the time) isn't the right answer.



Solution 1:[1]

In case you are using JavaScript to click those elements you do not need to wait for these elements clackability or visibility, presence will be enough in this case. So, you can use presence_of_element_located method here.
I would advice never use JavaScript clicking with Selenium until you have no alternative since Selenium is simulating human GUI activities which in 99.9% cases may and should be done with selenium .click() method. In case you can not do it with this method it will normally mean human will not be able to perform this action via GUI, so this is normally not what we want to do testing the GUI functionality with Selenium.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1