Answer the question
In order to leave comments, you need to log in
What could be the ways to define Selenium automation?
Let's say there is a site example.com where I'm trying to automate the registration process. The success rate is extremely low. What I tried:
1. Proxy. Public lists, private lists, luminati, microleaves - all with little or no success. I settled on the option of raising the google cloud microservers and running a proxy through them - occasionally registration occurs.
2. User-agent and OS naturally change randomly, only current versions.
3. There is a lot of randomness in the script itself - each input form is hovered over, clicked on the form, user data is not entered immediately, but something like this:
fn_form = WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.XPATH, '//input[@name="firstname"]')))
action = ActionChains(driver)
action.move_to_element(fn_form).perform(); time.sleep(random.uniform(0.1, 0.5))
fn_form.click()
for character in user_info['first_name']:
fn_form.send_keys(character)
time.sleep(random.uniform(0.1, 0.3))
driver.find_element(By.XPATH, '//body').send_keys(Keys.TAB); time.sleep(random.uniform(0.1, 0.5))
Answer the question
In order to leave comments, you need to log in
Tried a bunch of different options, here are some that might work for some (not for me):
1. Very doubtful, but some people say it worked for them:
Changing the name of the js document variable used by Selenium to $cdc_ . To do this, just open the chromedriver.exe file in any hex editor (I used HxD) and change its name to any other. It didn't work for me, but chromedriver itself works fine after that. I also tried to change all the variables where there are the words driver , but it was a bad idea - chromedriver stopped running. You definitely cannot do without changing the sources, but I'm not sure that this can work.
2. This is a more effective option that gives at least some result. On this page , you can determine whether chromedriver is used or not, and when you run this page through selenium, it really shows that webdriver is used. Adding the following piece of code helped bypass this identification:
But it still didn't help me.
I also found a very dubious and most likely simply non-working solution:
Running a js code that changes the state of navigator variables, including navigator.webdriver.
This is how it starts:
// overwrite the 'languages' property to use a custom getter
const setProperty = () => {
Object.defineProperty(navigator, "languages", {
get: function() {
return ["en-US", "en", "es"];
}
});
// Overwrite the 'plugins' property to use a custom getter.
Object.defineProperty(navigator, 'plugins', {
get: () => [1, 2, 3, 4, 5],
});
// Pass the Webdriver test
Object.defineProperty(navigator, 'webdriver', {
get: () => false,
});
callback();
};
setProperty();
You can also use Puppeteer instead of Selenium with the puppeteer-extra-plugin-stealth plugin connected .
At least this test passes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question