Testing Web GUI Through Selenium

Infotek Solutions
Jul 22, 2017 · 2 min read

Selenium tools can help us to locate the elements in a web application.This approach can be very useful to verify that the elements exists and are present in their correct location.It can be helpful if you want to confirm that a particular image has been loaded or not.You can use this feature if you have access to the source code of web page.This can be easily done by going to your webpage,right click anywhere in the page and select ‘View Page Source’ option.

The elements can be identified by many ways.Some of them are:

  1. By id
  2. By name
  3. By Xpath

More about xpath can be read here.

Verifying web elements

In Selenium IDE

Suppose we want that an error is to be reported by the IDE, if the actual thing doesn’t meet the software specifications. We can validate any GUI elements on the web page. Select the element that is to be validated during the test, right click it and you can find the assert commands,e.g:assertText ‘Some_text’,assertElementPresent ‘Facebook_logo’,etc.

If we want to validate the ‘Google logo’ in www.gmail.com. We just need to open gmail.com site. Start selenium ide so that the selenium can record the from the browser. Go to the google logo, right click it and select ‘assertElementPresent css=img.logo’.

Assert Image

If you don’t find this option, don’t worry. Right click the image and go to ‘Show all available commands’. You will get a list of commands that the selenium ide expects to include in your test script. You can find this command listed. Now go back to selenium IDE and observe the test script part. A command ‘assertElementPresent’ will be listed there. Run the test case. If the image is present on the gmail.com site, the test will report success. Otherwise, the error will be reported.

Verify Element Present on gmail.com

There is also another command:’verify’. It also performs the same action as ‘assert’.

You can also manually test for element.In the command field,type verify Element Present. Then in the target field,enter the expected location for the element.You can verify any element on the web page.It may be a text,an image or form elements.Then in the target field,enter the expected location for the element.We can use the ways described above to locate the element(by id,by name,etc).Now play the script and you will get the result.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade