As mentioned in the previous demo,
here we'll look at the other methods of locating elements,
but go through them a little quicker.
The next method is to locate an element using the ID.
Here we'll navigate to the official site of Python,
locate the search bar and type in lists.
How do we find the Id of the field?
We'll be following similar steps to what we did previously.
We'll open a tab and go to the website.
Go to the search bar and click on inspect.
As you can see in the highlighted text, id is id-search-field,
which is what we type in here.
We follow similar steps as the previous demo to type in lists and press Return.
There you go.
The next method is locate elements by link text.
What we want to do in this code block,
in addition to searching my name on Pluralsight,
is to click on my course link, which will take you to its main page.
Let's see how to do that.
We'll locate the element by name and follow the same
procedures to search for my name as before.
Then,
we use the find element by link text method and type in the exact link name,
which in this case is the course name.
Remember, with this method the name has to be exactly the same,
word for word, otherwise it'll throw up a no such element error.
This line will click on the link in question and take
you to the main page of the course.
Let's execute the block and see.
(Loading) The next method is locating elements by partial link text.
This is exactly similar to the previous method,
except for the fact that instead of typing in the entire link text here,
you can type it in partially.
I won't be running this as you've already seen what'll happen.
The next method is locating elements by CSS Selector.
Here again, we'll be going into Pluralsight,
locating the search bar, and typing in my name.
Except for the fact that we'll be locating the field using CSS Selector.
Let's inspect the field again.
Here you can see the CSS class is header_search--input.
To access the CSS class, we'll use the dot symbol.
So it'll be find_element_by_css_selector input.header_search —input.
Let's run this and see.
(Loading) And there you go.
Finally, we'll have a look at locating elements by XPath.
We'll try to do what we've done multiple times before.
If you've looked at the theory section,
you remember this part as being exactly how the basic
format of the XPath was defined.
If you inspect the element,
you can see that the search fields is in the input node,
and then you select the name attribute and give the value as q.
If you run that, you'll again reach the by now familiar result.
(Loading) We still have two methods remaining,
locating elements by tagname and classname.
This would be an excellent opportunity to give it a go yourself on
these since you should now be familiar with the basics.
If you run into any issues or if you have any questions,
please don't hesitate to ask in the discussion section below.