Monday 10 February 2014

How To Use DOM



The Document Object Model represents an HTML document and can be accessed using JavaScript. This location strategy takes JavaScript that evaluates to an element on the page, which can be simply the element’s location using the hierarchical dotted notation.

Since only dom locators start with “document”, it is not necessary to include the dom= label when specifying a DOM locator.
DOM stands for Document Object Model. DOM is convention for representing objects in HTML documents. Selenium interact with these objects using javascript.

</pre>
<form id="loginForm">Login Username: <input id="username" type="text" name="username" />
 Password: <input type="password" name="password" />
 <input type="submit" name="login" value="Log in" /></form>
<pre>
In this page, you can locate the highlighted input field using:
document.forms[0].elements[0]
document.forms['loginForm'].elements['username']
dom=document.forms['loginForm'].username
dom=document.getElementById('username')

You can use Selenium itself as well as other sites and extensions to explore the DOM of your web application

No comments:

Post a Comment