English 中文(简体)
Using Selenium-IDE with a rich Javascript application?
原标题:

Problem

At my workplace, we re trying to find the best way to create automated-tests for an almost wholly javascript-driven intranet application. Right now we re stuck trying to find a good tradeoff between:

  • Application code in reusable and nest-able GUI components.
  • Tests which are easily created by the testing team
  • Tests which can be recorded once and then automated
  • Tests which do not break after small cosmetic changes to the site

XPath expressions (or other possible expressions, like jQuery selectors) naively generated from Selenium-IDE are often non-repeatable and very fragile. Conversely, having the JS code generate special unique ID values for every important DOM-element on the page... well, that is its own headache, complicated by re-usable GUI components and IDs needing to be consistent when the test is re-run.

What successes have other people had with this kind of thing? How do you do automated application-level testing of a rich JS interface?

Limitations

  • We are using JavascriptMVC 2.0, hopefully 3.0 soon so that we can upgrade to jQuery 1.4.x.
  • The test-making folks are mostly trained to use Selenium IDE to directly record things.
  • The test leads would prefer a page-unique HTML ID on each clickable element on the page...
  • Training the testers to write or alter special expressions (such as telling them which HTML class-names are important branching points) is a no-go.
  • We try to make re-usable javascript components, but this means very few GUI components can treat themselves (or what they contain) as unique.
  • Some of our components already use HTML ID values in their operation. I d like to avoid doing this anyway, but it complicates the idea of ID-based testing.
  • It may be possible to add custom facilities (like a locator-builder or new locator method) to the Selenium-IDE installation testers use.
  • Almost everything that goes on occurs within a single "page load" from a conventional browser perspective, even when items are saved

Current thoughts

I m considering a system where a custom locator-builder (javascript code) for Selenium-IDE will talk with our application code as the tester is recording. In this way, our application becomes partially responsible for generating a mostly-flexible expression (XPath or jQuery) for any given DOM element. While this can avoid requiring more training for testers, I worry it may be over-thinking things.

问题回答

Record and Playback will not work in large scale testing. It may work for smoke tests and small repetitive tasks.

Instead of trying to generate unique IDs, try to solve that with CSS based selectors. Generating unique ids is ideal goal but I don t think that is possible in all practical cases.

If you trying to look for custom locators, it is better to look into BDD.

Can t you use css selectors with Selenium? That seems a little more straightforward than using XPath.

http://saucelabs.com/blog/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签