Testing Software- Selenium

Selenium is a software-testing framework for web-applications. It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including C#, Groovy, Java, Perl, PHP, Python, Ruby and Scala. The tests can then run against most modern web browsers. Selenium deploys on Windows, Linux, and OS X platforms.

It is a suite of software tools to automate web browsers. It is an open source and mainly used for functional testing and regression testing. It checks the functional(necessary) requirements of the web page.

Here, I am going to test the project “Certificate Generation System”. You can clone it from https://github.com/amisha2016/Certificates

Selenium Installation

For it, first install pip3 package.

pip3 install selenium

se1

The webdriver for Firefox is installed along with Selenium but if you want to test your applications on chrome then you need to download the chrome driver and ensure chrome is installed on your Linux distro.

sel.py file

#!/usr/bin/env python3
from selenium import webdriver
driver = webdriver.Chrome(“/home/amisha/Downloads/chromedriver”)
driver.get(“http://localhost/Certificate/CGS/index.php?cert=design4”)
assert “Academic Certificate” in driver.title
innn=driver.find_element_by_name(“in”)
innn.send_keys(“Selenium web test edit”)
asss=driver.find_element_by_name(“as”)
asss.send_keys(“Selenium web test edit”)
Submit=driver.find_element_by_value(“Submit”)
success=Submit.click()
assert “Institute Details Saved Succesfully!” in driver.h2

It is the python script which is used to test the page in the project. Similarly for your web-based project there would be a relevant script.

An assertion is a sanity(normal)-check that you can turn on or turn off when you are done with your testing of the program. If the result comes up false, an exception is raised.

Now, give the executable permissions to the python script

sudo chmod 755 sel.py

python3 sel.py

se7

se3se4se5

Correspondingly, you can do it for your own project.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s