8 ms·
>>my goodness, it'd be slow and potentially flaky all via the web UI for those sites Generally, I've had better luck using undocumented APIs for this kind of s
by dhruvkar 7y ago
>>my goodness, it'd be slow and potentially flaky all via the web UI for those sites
Generally, I've had better luck using undocumented APIs for this kind of stuff. I was a heavy user of Selenium to automate many a task (I work in wholesale construction goods, tons of automations needed everywhere).
But then discovered that using internal APIs (which surprisingly don't change much) is far easier than trying to exception manage changing UIs.
Open up dev tools on your browser and watch the GETS/POSTS as you complete your daily tedium. I use Python (usually just requests and beautifulsoup is enough) to mimic the calls and I have yet to find a use case where I wasn't able to automate something online.
I'm currently developing an SDK for our 18th-century ERP system, which has no API. I've also automated getting shipping container tracking data from a various shipping lines and railroad company websites, many with complicated login processes.
Happy to chat, email in profile.
- tech_tuna 7y agoHa ha, yep. I do this kind of thing all the time.
- 2rsf 7y agoGood point, using the APIs directly is the also the corner stone of stable test automation
- ctrl4 7y agoYup. I did this with a local Android app, that tells you the gps location of a public bus. I sniffed the http packets, found the requests i needed and made a python script that pinged me at slack when my bus was 5 minutes from my bus stop. Useful when I worked at night.
- spikej 7y agoI'm familiar with the web dev tools, but no clue about mobile. Can you point me in the right direction on how to do the same? Were you using an android emulator on desktop or there's some way to easily do this on android?
- dhruvkar 7y agoI use mitmproxy or charles proxy with an android emulator, with an older version of Android so it allows for a man-in-the middle, without being finicky about certificates.
- dhruvkar 7y agoNice, that's the next step up. Man-in-the-middle Android apps to discover (sometimes different API backend). I did the same with a shipping line which turned out to use a SOAP backend.
- beatthatflight 7y ago(Facepalm) I read your post. Paused. Opened up debugger on the site I'm currently selenium-ising. reloaded. boom. there it is. The request, and beautiful json response. So...so..so much simpler. Thank you, my evening is sorted ;)
- dhruvkar 7y agoHaha.. love it, I'm so glad it helped. I had the same experience a couple years ago after spending months selenium-ing our ERP software.
- beatthatflight 7y agofinally got to it last evening. 20 minutes of playing with json libraries, and I've got a ~10 line script that runs in under a second and produces output that would have taken probably a minute to run in selenium and occasionally been flaky too. /starts looking at other APIs to use! Thanks!
- dhruvkar 7y agoAwesome! enjoy the rabbit hole :D