Webdriver Marionette Driver

In Firefox version 47 and above, with selenium webdriver 2.53.x you would be typically facing “could not start a new session” error with firefox crashing down.

Starting FF 47 even firefox is moving in the direction of chrome, where they have created a all new executable driver – Marionette.

The setup is pretty straight forward. While you usually do –

WebDriver driver = new FirefoxDriver();

Replace it with its own driver class.

WebDriver driver = new MarionetteDriver();

Thats for the driver object creation part of it. Download the driver from here. Unzip and provide the location to the executable to the system property you are going to set in you framework (code).

System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");

Ok One last thing you need to do is, make it executable. Without it, it wont work. In windows this wont be an issue at all. In Linux based machines you have to to this from a command line, from the place were you have unzipped it.

chmod +x geckodriver-XXXXX

Thats it you are good to go. You dont have to set any specific capabilities or anything as such.

 

Cent OS webdriver http authentication

In one of the projects we had to have an https authentication to be able to get to the home page for security reasons. We were looking at various options to get through the authentication during the web driver tests. These were the few options we came across :

  • Remove the authentication itself ! Not a good idea, because we were having client specific information public, on the internet.
  • Another option is this , where they inspect each driver’s methods and call its version of HTTP basic as needed. For us it dint work either.
  • Another option is to use this URL : https://<username&gt;:<password>@<actual_url> and it generally bypasses the authentication. The only problem we had was, in nginx, you usually hit a blank “Site Content” page after which you are actually redirected to your site. But in this case, the redirection was not happening. Also with this method you would be exposing username and password in codebase if done in a simple way.
  • Next was to use the AutoAuth plugin of firefox.

This is plugin is simple. If there is a saved username and password in your profile , it directly fills in the data and takes you to the home page of the site. But here you have the task of entering the credentials the very first time and save it.

Typically centOS doesn’t have a GUI. We need to install the xvfb and start firefox in a display with it. After a huge setup process we were able to finally see firefox run with a GUI using VNC viewer. Finally we tried opening our site in that firefox but we weren’t able to enter the credentials. It might be because of some limitations on firefox running on CentOS. But only if we could enter the credentials the very first time and save it ,we could be able to run the tests without entering the credentials.

After few google searches we tried using Saved Password Editor plugin for firefox. With the CentOS GUI we were able to at least open this plugin and enter the credentials by clicking add new. All details are straight forward, except you would be specifying “Restricted” in “Annotation” when its a java script popup (which is the case here and other web server level authentications ).

After entering the credentials in the saved password manager, when you open the site autoauth automatically authenticates you in to the web page. After this the web driver ran like a breeze !

How to HTC M7 MIUI V6, ELEMENTALX KERNEL

I am not a big fan of vanilla Android looks, may be from the functionality stand point or the amount of bloatware (in other for eg HTC sense, touchwiz) I think vanilla is great. I haven’t used many ROMS apart from Cyanogenmod and MIUI. Cyanogenmod is one of the highly acclaimed ROMS out there, but I am not a great fan of it because of the vanilla style.

I have heard decent things about ROMS like Carbon, Pixeldroid, but I like and prefer MIUI. It might have that ‘colorful’ look, but the menus, settings, notifications menu, etc are pretty neat and easy to use. I was already running 4.2.2 MIUI V5 on my mobile for about a year now, and was waiting for a proper upgrade. I know there a bunch of 5.X.X ROMS out there, but I wanted something to suite my taste. Finally I found the link here (xda link). Its not an official MIUI release for m7. But this is an unofficial stable V6 running 4.4.2.

I had a little older version of CWM recovery, not sure if using that or not deleting data and cache were reasons for improper installation. I updated to the latest of TWRP. The best way to install is using ‘fastboot’ command. Flashifty or TWRP app dint do the job for me. After a proper install of TWRP i finally installed V6.

The next think I notice is the ‘HTC logo’ which was acting as a menu button earlier is not functioning now. After a decent research I found ElementalX kernel should do the magic. Even after trying installing a couple of times I wasnt able to get it work. Finally the xda devs original MIUI post itself had a link to the proper ElementalX kernel. For the nth and the last time and I tried to install. And voila … it did work. There are a bunch of tweaks you can make, while installing the kernel. One point to note is that, there was some kind of OTA for V6, after which the kernel was gone. I am not exactly sure how could we handle that.

Another challenge was installing gapps. There is this useless error which comes up in playstore which says ‘no connection’ (or sorts) even though you have proper internet on your mobile. The best way to get through this is flashing the gapps. Again I was able to find it in the orginal xda post.

MIUI V6 with Kernel ElementalX is one of the best combination for HTC m7 out there. Please dont forget to read the contents of xda posts before installing a ROM, like I did. Happy ROMing !!

Raspberry Pi – OMBC Guide – Mac

I had a thought to try out few stuffs with the Raspberry Pi 2 after buying it recently. The one thing which is easy and quite useful is creating a media/entertainment center. There are many blogs and tutorials out there. But this might be very specific to Installing using MacBook Pro, using a external HDD and an android remote.  The RasPi with good amount of interface is very easier to set up and running. All you would need is :

  • A PC/Mac (I used mac) to install to the card
  • An sd card, 8 GB, class 10 (for stability and speed)
  • Raspberry Pi 2
  • Keyboard and Mouse
  • Edimax WiFi adaptor (if using wireless Internet/ Android remote)
  • Yatse/Kore Android app (Android remote)
  • Power adaptor. Recommended 5V , 2A power supply.

Use the SD card adaptor to plug it into the slot (in case of mac) or a suitable microSD/SD card reader to mount the card. Mac has a weird issue of some times not recognizing the sd card. Its a very silly issue, chk this out to solve the problem(Yeah it solved my problem). Next step after mounting is the installation.

You can download OSMC here. Download the installer which will guide you through the installation process. Either you can choose to download the img file separately and use it during the installation process or you can choose to allow the installer to download the image. I used the version “2015.06-1” to install. According to the blog it was a latest stable version. Not sure why they dint have “RC” tagged to it.

After a successful install plug the microSD card to the RasPi. Connect power supply and HDMI cable and turn the power on and the TV. Thats it ! You would see a OSMC booting and eventually in few secs to the GUI. A mouse would be sufficient for the initial setup. Though selecting from a list (say language selection) can get tricky, because of the mouse sensitivity. I selected Dutch by mistake and took me a little while to figure it out.

I wanted to control OSMC using Android app. For this either you can connect RasPi using ethernet or a WiFi adaptor (I used Edimax). Using the WiFi adaptor was pretty straight forward. I plugged it and it worked right out of box (without any configuration or settings), but might require going into settings screen and selecting wireless. Select the wifi network and connect.

After connecting OSMC to your local network you can install either Yatse or Kore. I prefer to use Kore because it has got seek bar for videos. Inside app you can add device and it would immediately recognize the OSMC(kodi) running in your local network, select and you are all setup to use your android as a full function remote.

Next I tried to connect my external HDD, but it failed to mount. After a little research I figured out that you need to edit the file /boot/config.txt and add this max_usb_current=1. You can change the file by doing ssh into RasPi. The username/password is osmc/osmc. What you are essentially doing is changing the default current to 1A. Check this out for more information on this.

So there you have it. A media center which could play movies from your external HDD and also controllable from your android/iphone.

References :

D-link 2750u with Tikona

Recently I subscribed for Tikona broadband here in Chennai. It was a direct RJ45 ethernet cable for input. I dint think much before buying a Wifi router. I bought a D-Link 2750u ADSL2 modem + router. I thought this would be right thing to do because in case I change my internet provider it would easier to use the same modem. But after a a little digging I almost believed that this wouldn’t work with RJ45 cable but a ADSL line only. Before I lost hope I took a lot of time to figure out in various sites how to configure my modem+ router to work as a pure router.

Another minor problem which I had was the h/w version of the modem which I had. There are many versions of 2750u. Mine was V1. You could easily check the version on the modem of 2750u. V1 was not a common one and finding a firmware was a little difficult. For V1 i installed the one here in the downloads tab which has ‘V1’ on it. And finally I found the steps here, reply #73 from a person akhileshgs . Frist, thanks a lot to him. The steps which he put there :

  1. Reset router
  2. Internet Setup–> WAN Access Type–>>Ethernet
  3. Select Bridge and protocol and go down and select apply (Without changing any defaults)
  4. Wireless basic–> Uncheck multiAP isolation
  5. Change country to India
  6. Wireless Security–>Security mode–> WPA Only and change the password at the bottom (Without changing any defaults)
  7. Local Network–> Uncheck Enable DHCP Server
  8. Go to Setup Wizard–> Change WAN access type to Ethernet and select Bridge as protocol

He also provides step by step screenshots here . (Also available in original post ).

Thanks to the original poster again. I hope this post could be found much more easier than the original.

Robotium – basic setup and sample

Prerequisites

  • Java
  • Eclipse
  • Android SDK with updated path variable
  • ADT plugin in eclipse

Steps for setting up proper environment for automation

  1. Install java
  2. Install eclipse
  3. Install android sdk
    with proper installation typing “adb” in command prompt from any path should give you something like this …                          
  4. Install adt plugin in eclipse.                                                                                    Above points can referred here and here
  5. Set android SDK location in eclipse.                                                                            In eclipse go to Window -> Preferences -> Android. With proper ADT plugin installation it should appear something like this ….                                                      Provide exact installation location of the android SDK here. If successful set you will see this                                              
  6. Create AVD.  In Eclipse go to Window -> Android sdk and avd manager. This will open up the “Android SDK and AVD manager” (you can also open it from windows programs and android SDK). Click on new and provide name, target(android version), sd card size, resolution(built in). After filling in all the required fields hit “Create AVD”                                                                                             Select the AVD created just now and hit “start” and then “launch”. This should launch the emulator with the above selected configuration.

Now everything is setup for running Robotium tests.

Running the sample test

  1. Download the sample code from here. Unzip the file to some location.
  2. Import the code into eclipse. In eclipse go to File -> Import -> Existing Projects into Workspace.                                                                                                        On successful import of the projects you should see all the project files and folders visible in the package explorer of eclipse.
  3. Install the app in the emulator. Download the FileManager app from here. (this app is signed with the debug key, details about signing apps with your own keys can be found here). From the saved path open a command prompt and type – adb install <app-name>.apk                                 
  4. Open the app “OI File Manager”(the application we installed) and click on “Accept” and “Continue” (I havent handeled this in the tests). Now we are all set to run the test.
  5. Select the test and run as “Android Junit tests”.
  6. In few secs you could see running tests. First time it fails(its intentional) and creates a screenshot, which is a very useful information for debugging. You can check out the code for how the screenshot is captured, its not a robotium feature, its achieved using native android apis. Open the app in the emulator you could see the screenshot named as ‘testname…..’ . After viewing get back to the view below in the app, you can hit back in the emulator.
  7. Run the tests again, it should pass.

You can enhance the tests further and use it for automating your own/other apps.

References.

Sign apps with your key

When testing apps with Robotium it is required that the signature of the app and that of the test match. For apps created by us(or rather same IDE) it shouldn’t be a problem but for external(downloaded apps or apps not created by you) they don’t.

Every developer signs his apps with a key so that he is identified individually from everyone else. The apps built using eclipse by default is been signed by ‘debug’ key. The Robotium tests when run, using eclipse in our case installs itself as an app in the device/emulator. So essentially even our test gets signed using the debug key.

Now both these signatures should match. We cant sign our test using the app’s key because its obviously not at our disposal. What we can do is sign the app using our debug key. Now lets change the signature of FileManager app.

  1. Download the app from the above link.
  2. Download the re-signer jar from here. This jar is a drag and drop tool which rips off the signature from the app and leaves it off without any signature.
  3. Open the jar and drag and drop the app in the window.
  4. Provide file name of app and save. Now it will show the package and the main activity name. Save it some where, it is required when testing the app.
  5. Now that it doesn’t have any signature, lets sign it using debug key. Eclipse stores the debug key in a file debug.keystore in the location C:\Users\<username>\.android. Copy it to the java bin folder C:\Program Files\Java\jdk1.x.x\bin.
  6. Java comes with a tool called jarsigner which can sign files using the provided key. In the java bin folder open a command prompt in admin mode(it wont work without admin mode) and type this command.                                                                            jarsigner -verbose -keystore debug.keystore <filename>.apk androiddebugkey      The last part ‘androiddebugkey’ is the alias name of the keystore. After entering the command, when asked provide the password : android.
  7. You are done. You have the app now signed with the debug key.

Few hints/pointers

  • Always run in admin mode.
  • It might happen that the debug key has expired in which case, go to the debug.keystore location(provided above) and delete the file. Now come to eclipse select a android app/test and then hit Project -> Clean. A new debug.keystore file would have been created for you.

References