Site icon Tutorial

Selenium IDE | Locating the Elements

Locating the Elements

Selenium IDE | Locating the Elements

For many Selenium IDE commands, a target is required. This target identifies an element in the content of the web application and consists of the location strategy followed by the location in the format locatorType=location. The locator type can be omitted in many cases. One of the most fundamental techniques to learn when using WebDriver is how to find elements on the page. Let’s get started

The various locator types are explained below with examples for each.

For instance, page source could have id and name attributes as follows:

<html>

<body>

<form id=”loginForm”>

<input name=”username” type=”text” />

<input name=”password” type=”password” />

<input name=”continue” type=”submit” value=”Login” />

</form>

</body>

<html>

The following locator strategies would return the elements from the HTML snippet above indicated by line number:

Since the identifier type of locator is the default, the identifier, in the first three examples above is not necessary.

<html>

<body>

<form id=”loginForm”>

<input name=”username” type=”text” />

<input name=”password” type=”password” />

<input name=”continue” type=”submit” value=”Login” />

<input name=”continue” type=”button” value=”Clear” />

</form>

</body>

<html>

id=loginForm (3)

<html>

<body>

<form id=”loginForm”>

<input name=”username” type=”text” />

<input name=”password” type=”password” />

<input name=”continue” type=”submit” value=”Login” />

<input name=”continue” type=”button” value=”Clear” />

</form>

</body>

<html>

 

Go back to Tutorial                                                                                Go to Home Page

Exit mobile version