Hi, I would like to change a part of the code so that instead of randomizing the location of the click based on the center, we use the size of the button and click in a random area within it. I found where the changes should be made but I'm having a logic problem, if anyone could help me I would be grateful. Here is the part of the code that I believe we should change.
def get_center(element):
coords = driver.execute_script("""
var element = arguments[0];
var rect = element.getBoundingClientRect();
var centerX = rect.left + rect.width / 2 + window.scrollX;
var centerY = rect.top + rect.height / 2 + (window.scrollY || window.pageYOffset) + (screen.height - window.innerHeight) / 1.5;
return {x: centerX, y: centerY};
""", element)
return {
'x': coords['x'],
'y': coords['y']
}
def find_and_move(element, click=True, offset_x=random.uniform(0.0, 1.5), offset_y=random.uniform(0.0, 1.5)):
center = get_center(element)
**target_x, target_y = round(center['x'] + offset_x), round(center['y'] + offset_y)**