For some places there is no element can be positioned to

 

 

 As FIG no place for such elements or once there is no good way to use when positioning the positioning coordinates (reuse of last resort)

Here coordinate positioning can be achieved using the scroll bar to the right slide (to locate a place, then click the right plan to achieve the equivalent of the scroll bar)

1. First, how to get the script to make only one pixel coordinates need to locate a screenshot of the page (screenshot here need to pay attention to see next map)

 

 

 Into your computer's drawing tools will cut a good map you can get to the desired point coordinates (pixels displayed by default in the lower left corner)

2. After the acquisition is to achieve positioning coordinates

先导入   from selenium.webdriver.common.action_chains import ActionChains

ActionChains (driver) .move_by_offset (x, y) .click (). Perform () # Click coordinates x, y place, so it

 

If you are unsure own coordinate is not what you want you can first click to change context_click () Right-click on to see if the location of the ()

 

3. Note that when the coordinates using a coordinate again is carried out based on the original

For example, to locate the first time (500, 500) when you want to locate (250, 750) will write (-250,250) # can pass negative

If you do not want every addition and subtraction on the basis of the original, then you can each use the coordinates to cut back that is 

ActionChains(driver).move_by_offset(x,y).click().perform() 

ActionChains (driver) .move_by_offset (-x, -y) .perform () # here just will not need to click back to restore the coordinates

 

Last resort is not recommended!

Last resort is not recommended!

Last resort is not recommended!

 

Guess you like

Origin www.cnblogs.com/wulinmiao/p/11490575.html