From the course: Python Automation and Testing

Unlock the full course today

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

Locating elements by class

Locating elements by class

From the course: Python Automation and Testing

Start my 1-month free trial

Locating elements by class

- [Instructor] Along with the methods that we've seen so far we can also locate elements using the class attribute. Let's take a look at this along with a code example. The HTML class attribute specifies one or more class names for an HTML element. These class names are used to point to a calls in a stylesheet. Typically a class is used to group a number of elements that have the same format or the same transition or have the same form, color, or anything in common. We use this method to locate elements when we know the class attribute of one or more elements. The first element with a matching attribute value will be returned. Let's take a look at the HTML code that we have been using so far. So here, we have a heading element with a class, content. So I'm going to copy this class name so that we can use it in our code. Let's head over to the desktop where I'll go to the Working Code folder, and I'll open the code that we have been working with so far here. Since we do not need…

Contents