def highlight_element(self, locator):
        """docstring for highlight_element"""
        self._info("start")
        element = self._element_find(locator, True, True)
        parent = element._parent
        parent.execute_script("""
            element = arguments[0];
            original_style = element.getAttribute('style');
            element.setAttribute('style', original_style + "; background: yellow; border: 2px solid red;");
            setTimeout(function(){
                element.setAttribute('style', original_style);
        }, 1000);
        """, element)
    time.sleep(1.1)

  现成代码,直接使用。  也可用于robot。也可参见:highlight_element.py

posted on 2014-04-28 10:31  Wandy.Ying  阅读(228)  评论(0编辑  收藏  举报