I first used selenium on a java project a while back. Since then selenium has grown by leaps and bounds. With continued support and a myriad of bindings, it’s a tool to go to for automated testing. However, it does sometimes stumps you with nuances you’ve not seen in the past. One such quirk I came across this week was starting safari in a clean session state. Unlike Chrome and Firefox, it’s impossible to start safari in a clean session state. A clean session state means devoid of any hangovers, cookies, for instance is a good example.
The project I was working on was set up with cucumber features using capybara that in turn uses selenium webdriver’s ruby bindings for communicating with the browser. Like any astute developer, I googled for solutions.
Beware! Google search for ‘safari in clean session state’ may throw you off into a completely different direction. Here are some of those solutions that won’t work.
Pass clean_session state as true as an additional option when a new capybara driver is registered for Safari. However, this will not work. Because, there’s a comment in selenium webdriver’s code pointing out the fact that it’s still outstanding.
Open Safari with different flags like -n -b -F. This doesn’t work either. Even if it did, you will have to delve deep in selenium webdriver land to pass that option in and monkey patch a solution for this. Thankfully, it doesn’t work because monkey-patching is never a reliable way to fix bugs.
So, what’s the solution?
Well, the only way to fix it is by deleting the cookies before a feature run. Typically, add some code to delete cookies in a before hook for capybara to run before each feature.
It took a lot of trying, experimentation and patience to find this solution and sincerely hope it helps someone.
Providers are probably the most significant concept in Angular 1. Services and factories use providers underneath, which makes it even more powerful. Anyways, Angular 1 has two phases in it’s lifecycle - configuration phase and run phase. Providers are initialised in the configuration phase. In this phase none of other angular services, like, $http, $location and so on are available to use. I had to pass some values to a custom provider and the only way you can do it is through the config defined on the module.
I never knew you could do that and this tiny post is just a note to self as a reminder.
Given that I have used ruby-ffi in the past, I decided to give emscripten a try this time around. The installation guides are spot on and work like a charm except for one minor thing. For some reason, on running the emscripten (using ./emcc command) it complained about not finding python2. Not sure why it’s looking for python2 in the PATH, but I created a symlink to the installation of python in /usr/bin and called it python2 instead.
Hope this simple fix doesn’t cause any more issues later on.
Small devices equate to mobile, medium ones to tablets, large to desktops and extra-large to retinas. I understand the whole responsive thing to an extent but to learn a bit more about the tools and techniques out there, I took the Responsive Images course at Udacity. It was to the point, concise and free. Here are a few things I picked up: