Hello list,

I was trying to make a good selenium test for Plone workflow changes, and I
discovered some interesting things that I would like to share.

Probably everyone of you knew these things already, but I think it is very
useful to write them somewhere (I will merge this into the tutorial Beppe
was making, too):

1. It is better to always revise the selectors that Selenium generates: this
is because sometimes it generates selectors that look like this:
//[EMAIL PROTECTED]'plone-contentmenu-workflow']/dt/a/span[2]
where something like
//[EMAIL PROTECTED]'plone-contentmenu-workflow']//a/[EMAIL 
PROTECTED]'state-private']
would be much better as it doesn't break if someone changes the dt into a dd
or moves changes the span order.
Also, if you have an id, it is better to do something like
//[EMAIL PROTECTED]/$all_the_rest
by keeping the id in the beginning of the xpath selector and then travel
down for things that don't have an id. Don't use two id selectors in the
same xpath, because it's stupid and will make the test break on UI changes.

2. Don't use clickAndWait if there is no page reloading, because Selenium
clearly states that that command will wait for a page reload. Use instead a
click and waitFor* command.

3. Don't just text just for element existence: assertVisible and
waitForVisible are necessary in a lot of cases.

4. If, for example, you have some code like this:
<a id="mylink"
   href="some/url">
  <span>My text</span>
</a>
Don't issue a click command on #mylink but issue it
on //[EMAIL PROTECTED]"mylink"]/span. This is because the user will most likely 
link
on the text (so, the span) and not on the a element. Clicking on the a
element might masquerade bubbling issues as is the case for Plone workflow
changes.

I think that is all: if you want something to take as example you can take a
look at
https://svn.plone.org/svn/plone/plone.app.kss/branches/1.4-kss-test/plone/app/kss/demo/selenium_tests/run_as_testmanager/workflow_transition.html

Hope this information was useful :)

--
Simone Deponti (shywolf9982)

_______________________________________________
Kss-devel mailing list
Kss-devel@codespeak.net
http://codespeak.net/mailman/listinfo/kss-devel

Reply via email to