Used python selenium script to start selenium server to run JavaScript code. It works great.
drv.execute_script('<some js code>')
However, I cannot figure out how to run javascript code for an element that was obtained using get_element_by _ * () api. For example, I
ele = get_element_by_xpath('//button[@id="xyzw"]');
If I were on the browser developer console, I can run it as
ele = $x('//button[@id="xyzw"]')[0] ele.setAttribute("style", "color: yellow; border: 2px solid yellow;")
Just don't know how to do this in python selenium script. Thanks in advance.
source share