dimanche 17 septembre 2017

Python selenium - element.click() random position

Lets say I have this simple code that clicks on an element (which is a small box) which was located with xpath:

driver.find_element_by_xpath("/html/body/div[2]/input").click()

Correct me if I am wrong but selenium always clicks on the same position of the element.

How to make selenium click the element on a random position.

So something like getting the coordinate of top left corner and bottom right corner of the element, random a coordinate within the element and click on the element on a random position.

NOTE: This probably requires to modify the selenium library and I am new to python, so please make your answer in code or beginner-friendly.




Aucun commentaire:

Enregistrer un commentaire