I have:
x = b.find_elements(By.XPATH, '//body'))
if x:
x[0].click()
When I click body (as an empty space to close some customer select dropdown) it will click at the centre of the element, which actually clicks one of the options from the drop-down list.
Question: How to click (at 0,0) point of the selected element (so it will click in the left top corner of the element)
CodePudding user response:
I'm not sure this can be done with Selenium .click()
method but this do can be done with ActionChains
.
from selenium.webdriver.common.action_chains import ActionChains
action = ActionChains(driver)
action.move_to_element_with_offset(el, 3, 3)
action.click()
action.perform()
This will move the mouse 3 pixels down and 3 pixels right from the upper-left corner of the element el
you passing here and perform a click there.