Skip to main content

Posts

How to disable flash in FirefoxDriver/ FirefoxProfile / using java in Selenium?

For some tests using selenium automated testing with FirefoxDriver one can create a custom FirefoxProfile and disable flash in it. Here is the code I used for this.                 FirefoxProfile profile= new FirefoxProfile(); profile.setPreference("plugin.state.flash", 0); FirefoxDriver driver = new                                       FirefoxDriver(profile);

How to parse HTML/ extract data from HTML / using Java?

Java has a large set of APIs to parse HTML. To extract data from HTML  and perform any manipulation we should be able to parse it. jsoup provides a very easy to use , powerful and compact API to pare HTML and extract data. It supports DOM, CSS and jquery like selectors. It is designed for all types of HTML and will even parse HTML which is not perfectly valid. Example In this example we fetch BBC Sport , parse it to DOM and then select headlines using css-selector. Document doc = soup.connect(" http://www.bbc.co.uk/sport/0/ ").get();  Elements newsHeadlines = doc.select("#more-news-headlines li"); We can also provide HTML directly in a string.  A detailed documentation is available at jsoup website. You may start from official cook book available here . 

A chat with Virgin Mobile Sales Advisor- Just a Joke :)

I was browsing virgin mobile website when a chat window popped up. Here is the conversation I ad with sales advisor Emma :) Emma:  Hello, as a Virgin Mobile order specialist, I can help you set up a new mobile account and select a phone. Are there any questions I may help answer for you today? You:  hi Emma:  How may I help you today? You:  I want to buy ZTE Kiss on PAYG Emma:  Thank you for your interest in Virgin Mobile. Emma:  I'd be happy to help you through the next few pages of your order. Emma:  Just to check, do you currently have Pay Monthly Virgin Mobile or Virgin SIM on contract? You:  no i dont. You:  this is going to be my first even mobile number Emma:  Thank you for confirming. Emma:  Alright. You:  but there is a probme You:  problem* You:  I only have 30 pounds Emma:  You can get ZTE Kis at just £49.99. Emma:  Alright, then you can't order ZTE KIS today. You:  oh So...

Find and remove duplicate files in Ubuntu / Mint Linux

If you have accumulated thousands of files , some times you will have more than one versions of same file. If you use Ubuntu of Mint linux you can find and remove these duplicates very easily. There are two popular tools for this fdupes and fslint Using fdubes ftubes is the most popular, simple and powerful tool to find duplicates and remove them. It is a command line tool so if you don't like command line move to next heading. It compares file size  and MD5 signatures(Do not worry if you don't know what it is). So it will find duplicates even if they have different names. Installation From terminal execute following command  sudo apt-get install fdupes ftubes Syntax fdupes [options] directory where  options available are -r --recurse include files residing in subdirectories -s --symlinks follow symlinked directories -H --hardlinks normally, when two or more files point to the same disk area they are treated as non-duplicates; this ...

Sumatra PDF Viewer for LaTeX users on Windows

If you use LaTeX on Windows, or in particular pdflatex , you must have noticed that viewing the resulting PDF file is not as easy as you would like it to be. Many PDF readers cannot update PDF automatically when you make changes, and you will have to close PDF reader and open PDF again. Sumatra PDF on other hand will read new PDF as soon as it is updated and you don't and will save your time.