Once upon a time, I had written a python script that logged into my work’s website and copied my work schedule out to my own calendar. I set it up to run once a week on my VPS (www.jmthomas.tech) because adding these events manually was a PAIN. It worked really well…until it didn’t.
One day it just stopped working, the script could no longer log in and would get an authentication error. I noticed this would happen if I let autofill filled out the form on the site even in “normal” usage, too. After a bunch of troubleshooting, I eventually gave up and forgot about it. I had tried clicking on the input fields a few times (automated) and pressing Tab, but the site still did not let me log in.
I was contacted by someone that was trying to use the script and asked if I had been able to fix logging in which I had reported as a problem on the README. I’d never intended for anyone to use it but myself but someone being interested renewed my own interest in fixing it. So, I thought some more about why I might not be able to log in and had the idea that perhaps the site could tell it was a bot logging in and was denying it. Was there a way in selenium to hide the fact?
Nope.
Google always has your back though, I found a post on StackOverflow that described how sites could detect you’re using a WebDriver by checking for a certain variable. They suggested just renaming the variables in the binary and gave a sed/perl command you could run on chromedriver to do just that. It renamed the variables from cdc_* to dog_*. The dog_ isn’t important, just that it’s the same length as cdc.
As far as I can tell, this doesn’t break my particular use case and the bot was able to log in again. I pushed an update to the README and hosted a copy of my modified binary on github and told the user the problem was resolved. They never got back to me, but hopefully it worked for them too.