Posted: February 18th, 2011 | Author: David Herman | Filed under: general | No Comments »
Need to generate a large file fast to test a large file based operation? The yes command is your friend. Simply redirect the output of yes to a file and then ctrl+c to stop it. After about 10 seconds I have a 248 meg file.
My commands
yes > yes.txt
^C
dhermanmac:file dherman$ ls -lh
total 508504
-rw-r--r-- 1 dherman EDIETS1\domain users 248M Feb 18 15:25 yes.txt
dhermanmac:file dherman$
Posted: February 2nd, 2011 | Author: David Herman | Filed under: general | 2 Comments »
Today I was working on writing a selenium test to ensure a feature was working properly on our site. The button I was trying to click had a duplicate button on the page and each did something different. The problem was that they were both in different forms, but had the same name and no ID. In selenium the only way to target the specific button is via XPath. The XPath for this is a little crazy:
//div/div[2]/div/div/div[2]/div/div/div[2]/div[2]/div[2]/div[2]/div/form/input[13]
Now I spent a bit of time trying to figure it out manually and quickly gave up. I figured firebug might have something and sure enough if you “Inspect Element” on the button firebug pops up with the full html path to the element shown across the top of the firebug window. Hovering over each element gives you the full XPath and right clicking lets you do a few different operations such as Copy Html and Copy XPath. Now the XPath that it gives you will look like
/html/body/div/div[2]/div/div/div[2]/div/div/div/div[2]/div[2]/div[2]/div/form/input[13]
I removed the /html/body and replaced with // to match the rest of the XPath that selenium generates, replaced the name=fieldname in my test and it worked.

*Please NOTE*
This is horrible don’t ever use it
– All joking aside if you have the option to add a class or an id(as rasenplanscher points out in the comments below) to an element on the page that you need to target you should do that instead. If you can’t like this situation, this will work for you.