I am new to selenium and I am wondering if I could draw a red circle around anything my selenium script clicks before taking a screenshot of the page (I already know how to do the screenshot). I think that I could utilize:
ele.location
and
ele.size
to draw a circle, but I just do not know how. Any input is appreciated.
CodePudding user response:
You can do the following. Let say you have a button
You can select it as
button = driver.find_element('xpath', '//button')
And then outline it
outline_style = driver.execute_script("return arguments[0].style.outline", button) # Get initial outline style
driver.execute_script("arguments[0].style.outline = '#f00 solid 5px';", button) # Change outline style
button.click()
driver.execute_script("arguments[0].style.outline = arguments[1];", button, outline_style) # Set back initial outline style
Yes, it's definitely not a circle, but if you need to somehow make a focus on element you can use this approach