Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Selenium 2’s Python bindings, use ActionChains to move the mouse by an offset, then click at its current position:

from selenium.webdriver.common.action_chains import ActionChains

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

This is a relative pointer move, not a command to click absolute desktop or screen coordinates. The offsets start at the pointer’s current position, and the queued actions run when you call perform(). If you can identify the page element, clicking that element directly is usually clearer.

What “arbitrary position” means in Selenium 2

Selenium 2’s Python ActionChains API lets you describe pointer actions without passing a page element to click(). In the coordinate pattern, move_by_offset(x, y) moves the pointer relative to where it currently is; click() with no element clicks at the pointer’s current position. The Selenium Python Bindings 2 Action Chains documentation describes these methods and the queued-action model.

That distinction matters: x and y are not coordinates measured from the top-left of the monitor, browser window, or document. The reviewed Selenium 2 documentation does not provide a general conversion formula between those coordinate systems and the browser pointer. If you need an operating-system-level click or a point mapped from a screenshot, this API pattern does not, by itself, establish that mapping.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Click at a point relative to the current pointer

Use this pattern when the target is genuinely point-based and you know the desired offset from the pointer’s current location:

from selenium.webdriver.common.action_chains import ActionChains

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

Here, driver is your active Selenium WebDriver and x and y are integer offsets in the pointer movement. The first line creates an action chain; the next two queue a movement and a click; perform() dispatches them in order. The Selenium 2 documentation explains that actions remain queued on the ActionChains object until perform() is called.

A complete script shape

The example below opens a page and then makes a relative pointer move. Replace the URL and offsets with values appropriate to your page and browser session. It is deliberately not presented as a universal screen-coordinate conversion: the target position depends on where the pointer is when the movement begins.

Rank #2
Sale
Logitech G305 Lightspeed Wireless Gaming Mouse - Black
  • The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
  • Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
  • G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
  • Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
  • The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

url = input("Page URL: ")
x = int(input("Horizontal pointer offset: "))
y = int(input("Vertical pointer offset: "))

driver = webdriver.Firefox()
try:
    driver.get(url)
    ActionChains(driver).move_by_offset(x, y).click().perform()
finally:
    driver.quit()

This uses Selenium’s Firefox WebDriver interface and assumes the browser driver is available to the Selenium installation. The click occurs after navigation returns; if the page has not reached the visual state you need, first establish that state in your own test flow. The sources cited here define the pointer action behavior, but do not prescribe a page-specific readiness strategy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why the final call matters

ActionChains stores actions in a queue. Building the chain does not itself fire the events; perform() is the execution step. If you omit it, the intended movement and click have not been dispatched. You can chain additional documented actions before the final call, but keep the sequence explicit so it is clear which pointer position the click uses.

Click relative to a known element instead

If you have a WebElement and need a point inside it rather than its ordinary click behavior, Selenium 2.3’s manual documents move_to_element_with_offset(element, x, y). In that historical manual, the offsets are relative to the element’s top-left corner:

Rank #3
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)
ActionChains(driver).move_to_element_with_offset(element, x, y).click().perform()

This differs from move_by_offset(): the movement is anchored to an element rather than the pointer’s current position. It can make the origin easier to reason about when an element is available. For an ordinary button, link, or other identifiable control, prefer the element’s normal click when a point-specific interaction is not needed.

Version wording is important. The Selenium Python Bindings Documentation, Release 2.3 documents the historical top-left origin. The current Selenium Python API describes move_to_element_with_offset() offsets relative to the element’s in-view center. Do not apply that current description retroactively to Selenium 2.3 code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Approach Offset origin Best fit
move_by_offset(x, y) Current pointer position A point specified as a relative pointer movement, without an element reference
move_to_element_with_offset(element, x, y) in Selenium 2.3 Element’s top-left corner, per the 2.3 manual A point specified relative to a known element
element.click() The identified WebElement A normal click on a known control

Keep the target in the visible browser viewport

Pointer offsets must land on a usable position in the browser’s visible viewport. The current Selenium Python API documents an out-of-bounds exception when pointer movement targets a location outside that viewport. That is a current API statement; it should not be treated as proof that every Selenium 2 and browser-driver combination reports the same exception or handles the boundary identically.

Rank #4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
  • Computer mouse for easily navigating a computer interface; click, scroll, and more
  • USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
  • High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
  • 3 buttons offer effortless fingertip control
  • Plug-and-go ready for instant use
  • Check that the page is at the intended scroll position before choosing a point.
  • Keep the target within the visible viewport rather than assuming a document coordinate can be sent directly.
  • Verify the interaction in the specific browser and driver combination used by your test.
  • If the target is a normal page control, use its WebElement instead of estimating a point.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure modes and how to investigate them

The click appears to do nothing

First confirm that the chain ends with .perform(); actions are queued before that call. Then check that the intended page state and pointer origin are correct. With move_by_offset(), the offset is relative to the pointer’s current location, so assuming a fixed absolute origin can put the click elsewhere than expected.

The target is outside the viewport

Reposition the page so the target point is visible and use offsets that remain within the browser viewport. The current API documents an out-of-bounds movement exception for an outside target. Because that detail comes from current documentation, inspect the behavior of the actual Selenium 2 binding and browser-driver pair if you are maintaining a legacy test.

An element-relative offset lands in the wrong place

Check the version-specific origin before adjusting the numbers. Selenium 2.3 describes offsets from the element’s top-left; current Selenium Python API documentation describes the in-view center. Mixing those definitions shifts the intended target. Confirm the binding version and follow the documentation for that version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.

A coordinate copied from a screenshot does not match

The documented Selenium 2 methods here use either the current pointer position or a WebElement as their origin; they do not establish a universal conversion from screenshot pixels to browser pointer offsets. Avoid assuming that browser chrome, page scrolling, display scaling, and driver behavior can be collapsed into a single formula from these method definitions. Prefer a DOM element when one is available, or validate the exact coordinate mapping in the environment where the test runs.

Or skip the browser setup

If what you need is a visual record of a page rather than a coordinate-driven browser interaction, ScreenshotNeo can return a screenshot or PDF from one GET request. It does not perform Selenium clicks; it is an alternative for capturing the page.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for request options. Before capture, it can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and whether the request was billed. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up free for 1,000 screenshots a month, with no card required.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the right click method

  • Use WebElement.click() when the target is an identifiable page element and you want a standard click.
  • Use move_to_element_with_offset() when a point within a known element is required, applying the Selenium 2.3 top-left origin for that historical API.
  • Use move_by_offset() when the interaction is genuinely defined as movement from the pointer’s current position.

Frequently Asked Questions

Can Selenium 2 click at absolute desktop coordinates with this method?

No. The documented method moves by an offset from the current pointer position; it is not a direct absolute screen-coordinate API.

Why does the element-offset example differ from current Selenium documentation?

The Selenium 2.3 manual gives the element’s top-left as the origin, while current Selenium Python API documentation describes the in-view center. Use the semantics documented for the binding version in your project.

Quick Recap

SaleBestseller No. 1
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Product carbon footprint: 3.97 kg CO2e; Contoured shape: Gives you more comfort and control
$14.90
SaleBestseller No. 3
Bestseller No. 4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Computer mouse for easily navigating a computer interface; click, scroll, and more; 3 buttons offer effortless fingertip control
$9.70

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.