Maybe you met similar problem in your testing live...
During execution of the test I recived information form console that element could not be scrolled into view. I found out that probably using java script executor is the solution. It's a dropdown.
There are 2 onclicks, which refer to 2 stages of action, all of them include dynamic number:
onclick="selector('phone_dynamicnumberlike98046454')" - general
onclick="pick('phone_dynamicnumberlike454674645',event)" - choose the type from dropdown
So if I want to use it I probably have to refer to dynamic id as an argument:
driver.execute_script(selector(dynamic id?);)
Now I refer to dynamic id using starts-with and contains:
driver.find_element_by_xpath("(//*[starts-with(@id, 'phone') and
contains(@id, 'dropdown')])").click()
And in next line I refer by xpath and by value to the type of phone.
How do I correctly replace this line of code by using javascript executor? I mean what is best practise in python, selenium?