Products Solutions Contact TR

Test Automation using Selenium

   

Selenium is a test tool that automates tests. With the Selenium-IDE that also has a Firefox extension, you can easily automate your tests without learning any required programming languages.

 

Test automation;

 
  • supports regression tests.
  • provides quick feedback for developers.
  • allows repeating test cases.
 

A Javascript library was developed for re-running Selenium in multiple browsers. As a result, Selenium Core, the basis of the Selenium IDE and Selenium RC (Remote Control), was created. Javascript security restrictions of browsers have made some situations impossible for Selenium. That’s why WebDriver was developed.

 

Selenium Tools:

 
  • Selenium IDE: a tool with a Firefox extension to create test commands. Using the Selenium IDE, test cases are recorded and executed so that reusable test commands are generated.
  • Selenium RC: allows multiple tests to be performed continuously and works with a Selenium RC server.
  • Selenium Grid: can work with multiple servers similar to Selenium RC. It works parallel, which means it can run different tests on different remote machines at the same time.
  • Selenium WebDriver: does not send Javascript functionality to the browser as a method of Selenium RC.
 

For example, let’s write a small test using Webdriver in Python. Firstly, you need to install the Selenium module for Python. Then, let’s open Kartaca’s Turkish web page with our application and check the title information.

 
import unittest
from selenium import webdriver
class FFKartacaTest(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
    def test_baslik(self): 
        self.driver.get("http://www.kartaca.com/TR/home")
        self.assertIn("Kartaca - Home", driver.title)
    def tearDown(self):
        self.driver.close()
if __name__ == "__main__":
    unittest.main()

We can write multiple tests into the class we define. Tests run in alphabetical order (according to the name of the method), and after each test, the tearDown method is called automatically. We can use Firefox’s Firepath and Firebug tools to find the browser elements that will interact with the program. The elements can be found by the class name (find_element_by_class_name), by CSS (find_element_by_css_selector), by the element id (find_element_by_id). These elements can be a form element or a menu. We can fill out forms using Webdriver’s methods and navigate pages by clicking on the links.

   
%d bloggers like this: