From the course: Python Automation and Testing

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Locating elements by ID

Locating elements by ID

From the course: Python Automation and Testing

Start my 1-month free trial

Locating elements by ID

- [Instructor] The very first step in test automation is to locate HTML elements. Let's take a look at locating elements using the id attribute along with a code example for the same. The HTML id attribute specifies a unique id for an HTML element. The rules for the id attribute are: it must contain at least one character, it must not contain any space characters, the id value is case sensitive, and it must be unique in a document. We use this method to locate elements when the id attribute of an element is known. The first element with a matching attribute value will be returned. Let's go ahead and try a hands-on on how to locate the elements using the id attribute. I'm going to head over to the exercise files where under chapter two I have an HTML code file that we will be using for the whole of chapter two to run our code. So I'm going to open this script with sublime text. As you can see, we have a form element with id loginform. We'll be writing a python script to locate this…

Contents