Translate

Saturday, July 23, 2016

The Way to Locate Targets In Selenium IDE

This is one of the most difficult things if you have even a semi-complicated website. There are multiple ways to locate targets. One of the easiest, is to use the select next to the target input box in selenium then all you have to do is click on the element that you wish to target.
The way it works is that there are multiple ways in which you can ‘target’ a html element. One of the easiest and frankly the best way is to make sure to assign a unique id with each element that is on your webpage. This means that in the target field all you have to put is id=sampleIdCall.


Just to note that the id is of the html element.


Another way is through CSS. This allows you to check all sorts of things. I’ll give a few examples.  css=span:contains("New Document");This checks the document for an element span with text containing “New Document”. Another is css=div.save-status searches for a element div with the class name save-status. These are just 2 examples of css and there are plenty more that I did not specify that are just discovered as you go on.


Another way to identify targets is through something called xPath and is literally the html path to that specific element. It does have a couple different syntaxes. One is to write out every element on the path to the one that is your target, this can be long and a little unnecessary for 99% on the time. That 99% of the time you are using xPath you can do whats call a shortcut. For example, xpath=(//input[@id='rename-document-input'])[2]. Now this is a input box that has a id that may match another element’s Id therefore to clarify we use the [2] to indicate that it is the 2 input box with that Id.
I could probably write a couple pages just on locators but this should suffice for now. Just to note that this is not all inclusive there are many things that I have used that I did not put as examples and many things which can be used which I have never used.


More References:



If you have any questions or comments leave them below.

1 comment :

  1. This is very informative blog and nice article , I really like your technique of writing a blog. I book marked it to my bookmark site list and will be checking back in the near futureselenium training,selenium online training,selenium training online,selenium free course

    ReplyDelete