Tuesday, March 25, 2008

Gospel Goes Green

CBC Radio, The Current, 24 March 2008 featured an interview with Rev. Richard Cizik, Vice President for Government Policy with the National Association of Evangelicals, the most powerful religious organization in the United States with over 30 million members. He is encouraging his flock of 30 million to "proselytize in the fight against climate change as well as the battle to save souls."

On a trip last August, he along with other evangelicals and scientists went to Alaska to see the effects of climate change. Asked about the impact of the trip, he said it was "an extraordinary experience for me personally as well as for all evangelicals."

The group saw first hand the impact of climate change, habitat destruction, and species extinction. Stressing the need for cooperation between the religious and scientific communities, Cizik recounted "...all these things that we together believe threaten the planet."

"It's one of the most important conversations that has to occur if we're going to be able to merge the concerns of these two worlds of religion and science on behalf of something that is surely one of the greatest challenges facing the planet - that of climate change."

In Alaska, the group saw melting of glaciers, rising sea levels of Shishmaref and the "great ghost" fir trees destroyed by bark beetles on the Kenai peninsula. Cizik said the impact of climate change is hitting close to home and that seeing it in the US is "critical" for Americans to understand.

It's clear he is passionate about the issue. "People are impacted too! Inupik Indians forced to consider leaving and losing entire way of life... the impacts are human!"

Although the group members didn't shy away from topics of creation and evolution, according to Cizik the debate is not how the earth was created (God is already well aware of that, he quips) but rather, what we do with the earth He created. He cites the Genesis 2:15 mandate to protect and care for the earth. "More import than how it all came to be is what is happening to it NOW."

The enmity between religious and scientific communities is a thing of the past, according to Cizik. "Science helps us to know what creation is telling us about itself - science is our partner in this. Science has been viewed as an enemy of the faith... that view has frankly gone by wayside for most people."

He admits that there is residual impact from the fundamentalist attitude, saying it is why large segments of the American public are skeptical about climate change, and why the GOP congress has been reluctant to act.

"This is new territory for a lot of people", he added.

Having demonstrated a much more forward-looking attitude than the religious right in recent times, it nevertheless surprised many when the Vatican revised its 1500 year-old list of Seven Mortal Sins to include "causing damage to the environment". The revised list :

1.) genetic modification
2.) carrying out experiments on humans
3.) polluting the environment
4.) causing social injustice
5.) causing poverty
6.) becoming obscenely wealthy
7.) taking drugs


Cizik calls it "a reappraisal of theology itself," and says that evangelicals have been slowest to this. Times are changing, however.

"The mainline has been on the sidelines... the irony is the community that has been least equipped has become the go-to religious community in Washington on policy changes with respect to climate change.

Cizik believes the influence of the religious community is the only way that the republicans are going to move in the policy debate. It has, he says, moved George W Bush from barely even recognizing it to saying, in his last State of the Union address "it is here".

Speaking of the beginnings of his own environmentalism, Cizik said he made a turn about face at a conference in Oxford, UK several years ago.

"I thought I was well positioned as a mugwump... don't push me, the science is split; I dont need to make decision, I don't have to engage evangelicals in this."

But the scientific evidence he saw at that conference swayed him.

"Wow... I saw with my own eyes the impacts that climate change is having upon the world. It's like I had a St. Paul's conversion. It was not by looking at the earth per se... I had it looking at the science."

He recalls thinking, "How can this be? That I myself in this case for 18 years a representative of the association here in Washington, that I could decide based on whatever evidence we had that I had no dog in this fight, so to speak? And yet I couldn't have been more wrong!"

"We all have blind spots. We evangelicals have been the blindest of all. It was a conversion for me at Oxford in England that brought me to this place. Well, I turned around and went in another direction. Yes, In some cases we evangelicals need to repent and turn around. I don't apologize for that term. I say, what is it if you turn around and go another direction except a conversion?"

Cizik insists that principles of caring for the earth are taught all the way from Genesis to Revelation, and says the religious community has been misguided by political interests.

"We've participated in an unholy alliance with big business. Those are the two components of the Republican party, the conservative moralists, the evangelicals, fundamentalists... along with big business. We're the two wings of this political party. We're 40 to 50 percent at least if not more. And we've participated in an unholy alliance over the years in which we've gotten very little andthey've gotten a lot. And one of the things they've gotten is a free run over our energy policy and our environmental policy. This is what's got to change."

Cizik is encouraging people not to put politics ahead of faith by "focusing on one or two hot-button issues". He criticizes the religious right for putting their tent in the wrong camp, and says that pro-lifers who say abortion is the main issue need to have a broader agenda. "We see hundreds of millions of lives at stake because of climate change today. I say broaden your understanding of what it means to be pro-life." The younger generation, he says, is keenly aware of these issues that will be among the most important issues they face throughout their lives. Many have been left politically homeless. Cizik sounds as if he may be among them. "I don't know who I would vote for," he admits. But he claims he predicted years ago that no non-green candidate would be elected to the republican party in 2008.

Cizik explains that historically, environmentalism has been associated with democratic blue state politics, leading many Evangelicals to view it with suspicion. Evangelicals who oppose evolution have also therefore opposed science, as a proponent of evolution, and have been skeptical of media. He calls it "a tribal kind of attitude", a "narrow fundamentalism" that is not based on sound principles of faith and wrongly ignores "undeniable realities."

The entire segment can be heard on CBC's web site at http://www.cbc.ca/thecurrent/2008/200803/20080324.html

Thursday, March 20, 2008

Selenium IDE Test Tips


Here are a few things to bear in mind when creating Selenium IDE tests.

Setting and Getting Variables

store | 10 | x

This obviously sets x=10. There are a couple of ways to reference it: ${x} or storedVars['x']. They're not the same.

The first, ${x}, is from Prototype. Its a shortcut and returns a copy of storedVars['x'], it doesn't actually point to the real value. The second, storedVars['x'] directly references the array of Selenium's stored user variables. I recommend using storedVars['x'] and not ${x} (even though it's shorter).

You can't assign anything to${x}. Within a single Selenium command, if you modify storedVars['x'], the value of ${x} won't get updated until the next command. Stick with storedVars and you'll be ok.

When you want to use a previously stored variable as an argument to a subsequent command, use the "javascript{...}" notation. For example:

assertElementPresent | javascript{storedVars['myElementsXpath']}

XPATH from Firebug

You tend to use xpath queries a lot in Selenium tests. Sometimes figuring out the xpath expression for an element is a real pain. Firebug can help. Just click on the "inspect" tab and highlight the element you want. Right-click on it in the HTML code display and select "Copy Xpath" from the context menu. Paste it and give it a try. You may have to replace "/html/body/" with "//" though.

Xpath can get interesting. I like Zvon's tutorial.

Using storeEval

There are ways of defining functions even in Selenium IDE, but a simple approach is to use storeEval to run some Javascript code and put the result in a variable you can use for subsequent commands. For example, say you need to click on ButtonA if its present, or else click on ButtonB if its present. If neither one is present you want to do something else.

In this example I've got my xpath expressions for ButtonA and ButtonB stored as variables (just to illustrate the aforementioned javascript{} syntax). I'm going to fetch them and use them in my evaluation.

storeElementPresent javascript{storedVars['ButtonA_Xpath']} ButtonA
storeElementPresent javascript{storedVars['ButtonB_Xpath']} ButtonA
storeEval (storedVars['ButtonA']==true)?storedVars['ButtonA_Xpath'] :((storedVars['ButtonB']==true)?storedVars['ButtonB_Xpath']:null); linkToClick



That's one way to do it. Another is to use conditional logic and flow control to set up an if-else structure. Check out the Selenium IDE FlowControl post for info on how to do conditional logic-based flow control.

In the end, if you're testing a web application you've designed and your test case is getting this ugly, you'd better re-evaluate your design. If you're testing something other than a web app though, for example a test case that spans multiple sites, you might need to get creative.

Tuesday, March 11, 2008

What I Don't Like About Google

As with all good things that must come to an end, the pure spartan simplicity that defined Google at the start has begun to cede ground to the ever-encroaching clutter.

Usability trouble comes in various guises but could be summed up in a word as "inconsistency". If I had a mantra for usability it would be "meet expectations". Which is impossible when your products set conflicting expectations. With all the additions, acquisitions, and new beta projects coming out of Google now we're starting to see the inevitable usability dragon rearing its ugly head.

It happens, for example, when you click on "My Account" in one application and it takes you to the app's dashboard, click it in another application and go to your Google account preferences. I don't want to have to remember that two identical-looking links in identical fonts in identical places on Google apps have completely different functionality.


Dear Google, please fix the inconsistency.

It snowed...

... a bit last night.

Monday, March 10, 2008

Selenium IDE Internals


When porting the original flowcontrol plugin for using goto and while loops in Selenium IDE (original Sideflow post) I found the following techniques useful for digging into the internals of Selenium IDE.

using getEval / storeEval

The functionality Selenium provides is great, but at times you may need to do something beyond the ordinary. One of the most useful commands in Selenium IDE for this is getEval. Get eval executes an arbitrary string of JavaScript code. If you've upgraded to the new Selenium IDE 1.0 Beta 1 you can also use the new "runScript" command.

getEval with alert

Most people will have tried this, I'm sure. Some say this is bad form, but I use this sort of thing all the time and it's usually the fastest way to get what I need for debugging.

|getEval | alert("simple is always better"); |
|getEval | alert("first command = "+testCase.commands[0].command); |
You'll want to remove these kinds of alerts once your test case is ready for production.

Selenium Internals

Selenium's greatest fault may be its poor documentation. Technical documentation is basically non-existent. These "can-opener" scripts can show you what's under Selenium's hood. They also show you how to open up a window and write stuff to it, an alternative to plumbing the depths of Selenium's inscrutable logging internals.

This will crack the Selenium object open for you:
|getEval| var result = "<h2>Selenium.prototype</h2><ul>"; for (var i in Selenium.prototype) { result += "<li>this." + i + " = " + Selenium.prototype[i] + " <br>";} result+="</ul>"; var debugWin = window.open("about:blank", "debugWin"); debugWin.document.open(); debugWin.document.write(result); debugWin.document.close();

Here's the browserbot object:
var result = "<h2>this.browserbot</h2><ul>"; for (var i in this.browserbot) { result += "<li>this." + i + " = " + this.browserbot[i] + " <br>";} result+="</ul>";var debugWin = window.open("about:blank", "debugWin"); debugWin.document.open(); debugWin.document.write(result); debugWin.document.close();

Try it with TestLoop.prototype, currentTest, testCase, and, of course, 'this'.

Looking at Constructors

Another handy trick is to check an object's constructor. It can be used sort of like a typeOf.
|getEval| alert(currentTest.currentCommand.constructor.toString());

How all these pieces fit together, and hacking new and nifty things out of them is left as an exercise for the reader (you).

Note: According to Matt Raible's blog post on the Selenium User's Meet-up, the next release of Selenium is going to feature some major changes including the merging of Google's webdriver code. So a lot of this is likely to change.

Translate