Frontend Development 9 min read

Bypassing Geetest Slider Captcha Using Selenium WebDriver

This article demonstrates how to use Selenium WebDriver with JavaScript to automate the Geetest sliding captcha, covering installation, element interaction, image capture, pixel analysis, and human‑like sliding trajectory generation to illustrate both the challenges and techniques involved.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Bypassing Geetest Slider Captcha Using Selenium WebDriver

The article introduces the concept of CAPTCHAs as a Turing test, focusing on the popular Geetest sliding captcha and its two main challenges for automation: image recognition and mimicking human sliding gestures.

It then explains that the W3C WebDriver standard enables browser automation and shows how to install the Firefox driver (geckodriver) and use the selenium-webdriver SDK.

const webdriver = require('selenium-webdriver');

Using an async function, a Firefox driver instance is created, navigates to the Geetest demo page, and confirms successful navigation:

async function() { let driver = await new webdriver.Builder().forBrowser('firefox').build(); await driver.get('http://www.geetest.com/type/'); console.log('success'); }();

After opening the demo, the script switches to the sliding verification tab via CSS selectors:

await driver.findElement(webdriver.By.css('.products-content li:nth-child(2)')).click();

It then clicks the verification button:

await driver.findElement(webdriver.By.css('.geetest_radar_tip')).click();

To locate the missing puzzle piece, the article captures the background canvas after hiding the full‑background image:

await driver.executeScript(`document.querySelector('.geetest_canvas_fullbg').style.display = 'none'`); const bgCanvas = await driver.findElement(webdriver.By.css('.geetest_canvas_bg')); const bgPng = await bgCanvas.takeScreenshot();

Since precise image analysis is complex, a simple heuristic is used: the missing area appears darker. Pixels are read using the get-pixels library, and the darkest pixel (lowest RGB sum) is considered the target location.

The sliding action is performed with WebDriver's actions API. First, the slider button element is located and its rectangle obtained:

const button = await driver.findElement(webdriver.By.css('.geetest_slider_button')); const buttonRect = await button.getRect();

Then a series of move, press, and release actions are chained to simulate a human‑like drag, adding random offsets and varying durations:

let actions = driver.actions({async:true}); actions = actions.move({x: x+10, y: y+10, duration:100}).press(); await actions.move({x: x+10+point.x-5, y: y+10, duration:1000}).release().perform();

To generate a realistic trajectory, the total distance is split into many small steps (e.g., 30) with random positive and negative offsets, mimicking the back‑and‑forth motion of a human drag:

const count = 30; // number of steps const steps = getSteps(distance, count); const totalDuration = 8000; // 8 seconds total steps.reduce((actions, step) => actions.move({x: x+10+step, y: y+10+_.random(-5,40), duration: _.random(totalDuration/count/2, totalDuration/count*2)}).press(), actions);

The helper functions getRandomDistribution and getSteps recursively divide the distance into random segments:

function getRandomDistribution(total, count) { let item = total / count; item = item + _.random(-item*2, item*3); item = parseInt(item); if (count === 1) return [total]; return [item].concat(getRandomDistribution(total-item, count-1)); } function getSteps(total, count) { const distribution = getRandomDistribution(total, count); return _.map(distribution, (item, i) => _.sum(distribution.slice(0, i+1))); }

Despite matching the puzzle perfectly, the Geetest system still rejects the attempt because it also validates the sliding trajectory. The article concludes that reproducing a believable human motion remains the hardest part of bypassing such captchas.

JavaScriptautomationcaptchaSeleniumwebdriverGeetest
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.