Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate DOM manipulation when using Selenium

Tags:

I'm using Selenium to test my application. A nice test would be that after every DOM manipulation I would validate the DOM. Is there a nice way to do this?

Obvious ways are:

  • use some builtin Selenium function. Is there one?
  • get the HTML of the DOM after the manipulation and use a local validator. However, I can't see how to get the HTML for the current DOM from Selenium.
  • I could go through javascript somehow, either by adding a JS file while testing or through Selenium. But I'm not sure how to go about this. Thoughts?
like image 262
Paul Biggar Avatar asked Dec 12 '09 12:12

Paul Biggar


People also ask

How does selenium interact with DOM?

DOM in Selenium WebDriver is an essential component of web development using HTML5 and JavaScript. The full form of DOM is Document Object Model. DOM is not a computer science concept. It is a simple set of interfaces standardized among web developers to access and manipulate documents in HTML or XML using JavaScript.

What is DOM locator in selenium?

DOM stands for Document Object Model. In simple words, DOM specifies the structural representation of HTML elements. There are four ways through which we can identify and locate a web element using DOM. getElementById.

What is DOM in automation testing?

The Document Object Model (DOM, see [DOM]) is a platform- and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure and style of HTML and XML documents.


1 Answers

There is no built in process for doing this using Selenium. There is however a Open Source project that is built on WebDriver, WebDriver is becoming Selenium 2, that allows you to do layout testing.

The project is at http://code.google.com/p/fighting-layout-bugs/ and was first shown at GTAC 2009 in Zurich. The code uses W3C and jQuery to check the validity of the DOM. Have a look at the video of the talk and the code that is there.

EDIT:

Thanks to sampablokuper the W3C validation is at code.google.com/p/w3c-markup-validation-filter/

like image 163
AutomatedTester Avatar answered Oct 11 '22 13:10

AutomatedTester