Skip to content

Commit cbebc1c

Browse files
author
Cleverson Sampaio
committed
feat(highlight): added support class for highlighting elements
1 parent a3d3037 commit cbebc1c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2022 Cléverson Sampaio <cleverson@sampaio.dev.br>
5+
6+
from robot.libraries.BuiltIn import BuiltIn
7+
8+
class Highlight:
9+
def __init__(self):
10+
pass
11+
12+
def init(self, locator: str):
13+
self.driver = BuiltIn().get_library_instance('SeleniumLibrary')
14+
element = self.driver.find_element(locator)
15+
if element:
16+
script = """
17+
original_style = arguments[0].getAttribute('style');
18+
arguments[0].setAttribute('style', original_style + ";box-shadow: inset 0 0 0 2px red;");
19+
setTimeout(function(){
20+
arguments[0].setAttribute('style', original_style);
21+
}, 500);
22+
"""
23+
self.driver.driver.execute_script(script, element)

0 commit comments

Comments
 (0)