So the next identifier that we can use and selenium web driver is called link text and
it's exactly as it sounds it's using the text of the link to identify an element. Now what
this implies is that there needs to be a link. Therefore if you want to do this for a button
without a link that's probably not going to work or something like a web it. Right. That
is not going to work for you. So for example if we want to click on this link using its
link text which is in here click me using this link text. Right. We're going to come
here. Copy over there's value for on Firebug. Go to our visual studio and we can uncomment
all of this which I have prepared for you guys control k you or as always you can come
here at it advanced on comments selection control OK you uncommon that commandeers Let's
run it. And if it's successful it is going to click on this link which takes us to a
link success page. OK. So let me go back and I am just going to shortcut keys actually
I'll show you guys a different way to run it. You can just right click and do run tests
or control our t and that's right exactly what I'm going to do. The test is going to
run it will be quick again but hopefully you guys will see that switch to the other page.
Click the link link success Tester's Don. And that should become green over here so
that you guys will see all successful.
And I'm not sure why it failed and actually did not fail. So my mistake guys over here
on the left side this is rechargers units the Rahner. And the way I ran it was using
Visual Studio's unit test run to see that two options here two options here. This is
resharpen and resharpen showing the old run. Right. Remember when we had like 33 failed
this the line 40 now.
So we can rerun it just like this. And I'm just going to go ahead and click here and
now see that there it goes. And this result should now be updated. Excellent. The test
passed and now you know how to find the elements using link tax. One thing that I quickly wanted
to try was to see what would happen if instead of using link taxed we used the tax of not
rolling. So I'm going to copy the text of this button and this button does take you
somewhere but I'm not using the link to it because this is not a link element. Well check
it out. There's a right here that tells you that it's a link right to a tag tells you
that it's a link. The other one wasn't a a tag it's a inport tat. So let's put that in
here instead. So that it's looking for the button. And what do you guys think will happen.
Think about it. You thought about it. Great. Now let's go ahead and run it and see if you
said that it would not work. You were absolutely correct. And this is for the exact same reason
as before no such element exception because selenium just was not able to find that element
because there is no element that has this in their link text. Looks like this bot this
text right here is replaced with this text right here. There is no link that exists like
that. So selenium just cannot find it.