Author Archives: drocpdp

python to js

Currently working on / investigating:

Python to JS compilers.

http://pyjs.org/
pyjamas

Current framwork in Python. Need to test Angular components, yet still couple our current framework without having to switch heavily to JS (Protractor) but still maintain the Webdriver context.

More to follow

Tri-state (Indeterminate) Checkboxes

What is the Tri-state? NY/NJ/CT. JK. Tri-state or indeterminate checkboxes are something i discovered recently. Here they are:

tristate

Ran into some trouble with them automating, as the “Indeterminate” state will somewhat misleadingly return a True with a “is_checked” attribute query via Webdriver. Actually I had no idea the 3rd state even exists (or should exist logically). Nonetheless…

Check out http://css-tricks.com/indeterminate-checkboxes/

So there will be 3 states that you should check for in order to determine your state:

First, you need to get a combination of two attributes, “checked” and “indeterminate”

  • [WebElement].get_attribute(‘checked’) –> (True, False)
  • [WebElement].get_attribute(‘indeterminate’) –> (True, None)

From these, you can gather the final state of the 3:

  • Unchecked –> checked == False, indeterminate == None
  • Checked –> checked == True, indeterminate == None
  • Indeterminate –> checked == True, indeterminate == True

 

How to take a cold shower (from an engineering perspective)

Recently, my hot water heater was disabled. (I had forgotten to pay the gas bill for awhile… Needless to say, I immediately enrolled in the auto pay plan).

I needed to take a shower. The water was cold. What do I do? Here are my strategies (I successfully completed it.) Hopefully they can help you too!!!

Preparation

It helps to have a removable handle shower head to direct water more precisely. You don’t want cold water splashing up.

The face and hair

If you’ve ever been to a fancy schmancy hair salon you know you can wash your hair and not let the water hit you easily by tilting your head back or forward and washing it. Same with the face really. Wash your face and hair first, then dry.

The extremities

These are the least sensitive to cold. Focus on these first. The feet, the legs, the arms and hands can be done one at a time. Do these first. Afterwards, your body should be used to the cold.

Your privvies

Your privates. Your legs should be used to the cold so when the water drips down… Enough said.

Your core

This is probably the most sensitive to cold. But honestly, by now, you can withstand about 20 seconds of cold water. Go to it!

Conclusion

Utilizing my slow-step-transition method, might as well disconnect your gas and/or water heater altogether and save some money! The economy is tough and hot water is for first-world-losers!!!

Utilizing shift and special characters with send_keys()

Today, had the most surprising blocker today.

Apparently, I’ve been automating for awhile and NEVER have had to send a shift-special-character key (the keys you access by pressing shift + normal keys such as !@#$%^&*() etc.)

[*NOTE — this is NOT the same as Keys characters which are sendable. http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver/selenium.webdriver.common.keys.html#module-selenium.webdriver.common.keys ]

I found out that you CAN’T send a shift-special character via send_keys. I think this is only a Firefox issue. In any case, after toying around with possible solutions, such as encoding/decoding, etc., here is my workaround.

SHIFT_KEYS = {
    "_" : Keys.SUBTRACT,
    "!" : '1',
    '@' : '2',
    '#' : '3',
    '$' : '4',
    '%' : '5',
    '^' : '6',
    '&' : '7',
    '*' : '8',
    '(' : '9'
}

def send_keys_filtered(driver, value, element):
    for i in range(len(value)):
        character = value[i]
        if character in SHIFT_KEYS:
            a = ActionChains(driver)
            a.key_down(Keys.SHIFT, element)
            a.send_keys(SHIFT_KEYS[character])
            a.key_up(Keys.SHIFT, element)
            a.perform()
        else:
            element.send_keys(character)


see https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html#typing-keys

In essence, i ActionChain a shift + key if I encounter a shift character.

Mavericks (Mac OS X 10.9.3) crontab changes

Had some problems with my cronjobs (Yes, I know that they are deprecated) on my iMac machine that I recently upgraded to Mavericks on. Did some research and found this.

touch ~/.crontab
sudo vi ~/.crontab

At this point, vi editor should open, edit your crontab, then exit out

crontab ~/.crontab

(Taken from http://robosights.wordpress.com/2014/02/10/getting-cron-to-work-on-mavericks/)

Technical QA Interviews

Giving interviews require a great deal of planning, skill, and preparation. After all, your goal is to assess a candidate whom you will be potentially committing to and investing a sizable salary on for months and even years, in the time span of 30-60 minutes. It is definitely, in my opinion, not a trivial undertaking. I have, in my experience learned, and also stumbled upon, a few tips and strategies though, that should allow you to make the most out of your limited time with your candidate to be able to successfully assess whether or not he/she is “the one”.

Presentation

You should always ensure that you are giving the candidate the Presentation you desire. The candidate should be impressed with your professionalism, and level of knowledge and experience. The candidate should even be somewhat intimidated. Not to the point where this becomes a power trip, but to the point where the candidate feels pressured enough to EXCEL.

Somewhat on a tangent, this is referred to (at least by me) as a paradigm shift. Honestly, in NONE of my interviews that I’ve been the interviewee have I 100% matched the qualifications desired. I learned Python about 3 years ago mostly because the new job I started required it. Previous to that, I didn’t really know Python. And this didn’t matter because I was able to show I had a penchant for the logic required to produce quality automation architecture/scripts. And there was some pressure, as I was required to deliver results within a timeline. Yet, the pressure was what drove me to subconsciously learn the language quicker, and in such a way to suit my needs to finish the frameworks.

Basically, what I’m saying is that the candidate needs to feel that he, if he successfully completes the interview process, will be joining a worthy, reputable, and well-established company/organization. When he is in the interview process, he/she feels motivated and “in the zone” enough to show his TRUE COLORS under pressure. Will he stutter? Will he think out loud and come up with a good workaround? Will he utilize his current knowledge, and although it may not DIRECTLY present a solution, be creative and nimble-minded enough to think out a great solution? Presentation of yourself (and the company you are representing) is paramount.

With that in mind, what makes a good Presentation by the interviewer?

Professionalism

  • Be on time to your interview.
  • Greet the interviewer heartily with a solid handshake.
  • Appear as if you are listening. TURN OFF YOUR CELL PHONE
  • Do NOT get distracted by people walking by, by meetings, by agenda that is work related. The interviewee is your SOLE FOCUS.
  • Do not chew gum, nor drink/eat to the point where this interview appears casual. This should be serious business. You are investing a lot of money into the candidate you choose.

Skip the typical questions

  • Go into the interview knowing what was asked by other interviewers before you. “Tell me a little bit about yourself” wastes about 4-5 minutes of precious interviewing time.
  • Spend some time to review the candidate’s resume. The interview is NOT THE TIME to do this. Do not go job-by-job asking your candidate for a summary of what his/her roles were.
  • (I actually will sometimes spend the entire interview focusing on one job/title and expounding even on one role solely).
  • Feel free to jot down questions before the interview so you are prepared.

Preparation

Somewhat inline and very similar to Presentation, is Preparation. Go into the interview prepared, and you will seem Professional and really on top of things.

  • Review the candidate’s resume.
  • Ensure that you know the title that the candidate is applying for and any caveats of the job that could be used as fodder for good detailed questions.
  • Eliminate any non-relevant job experience from your “questioning” and focus on any and all job experience that could be an asset to the current position being applied for.
  • DO ask your other interviewees their thoughts (and even their opinions) before going into your interview.
  • One of my favorite strategies is called the “hand-off”. Sometimes I will not have enough time to fully focus on a certain area of the candidate’s experience/knowledge, so I will tell my next interviewer “I wasn’t able to really get a feel of her jQuery knowledge, but know she’s good in javascript. Perhaps you could dig into her jQuery experience…”
  •  Don’t be afraid to research the company he/she used to work for. That could dig up some great revealing questions as well. I once interviewed a candidate who worked for a company that just recently implemented a solid social media single-sign-on platform. However, further research into the company and into his end date revealed that he had no part in that as he left the company before that was even implemented.

Induce Participation

The white board and/or a computer is your greatest method in seeing how viable his/her experience is.

CHALLENGE HIM/HER!!

  • “Show me what a round-robin is in Java”
  • “Show me some pseudo-code that addresses the following issue in this class”
  • “Give me some test cases for the following page assuming that there were no other business requirements hashed out…”

More later…

Git cleanup of already locked files

Taken from http://www.smooka.com/blog/2010/12/09/fix-git-lock-after-git-crash/

If you have either manually or by accident “breaked” in the midst of a git add or git commit, most likely the lock file of the file you attempted to git add/commit still exists, preventing you from further action on that file. There’s an easy way to solve this.

DIAGNOSIS:

L-MAC-DEYNON:my_project_dir deynon$ git add data/reports
fatal: Unable to create '/Users/deynon/Projects/dir_1/.git/index.lock': File exists.
If no other git process is currently running, this probably means agit process crashed in this repository earlier. Make sure no other gitprocess is running and remove the file manually to continue.

TREATMENT:

Delete the …/.git/index.lock file… and git reset…

L-MAC-DEYNON:test_and_target deynon$ rm /Users/deynon/Projects/dir_1/.git/index.lock
L-MAC-DEYNON:test_and_target deynon$ git reset

And you should be good!

 

Git mass delete by find

Oops. You transferred repositories. Or, by accident included all your compile and tmp files into your commit. There’s a cool solution. Of course, substitute “*.pyc” with whatever reg ex you need…

Found this on http://yuji.wordpress.com/2010/10/29/git-remove-all-pyc/

First, git rm them
find . -name "*.pyc" -exec git rm -f {} \;

Then, add a .gitignore file in the root of your repo and enter a line:
*.pyc

to prevent them from being added automagically in the future without an -f