Site icon Kartaca

Test Automation Using Selenium


Test Automation Using Selenium

   

Selenium is a test tool that automates tests. You can use multiple programming languages like Java, C#, Python etc to create Selenium Test Scripts. And also with the Selenium-IDE that also has a Firefox extension, you can easily automate your tests without learning any required programming languages.

 

Test automation;

   

A Javascript library was developed for re-running Selenium in multiple browsers. As a result, Selenium Core, based on 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:

   

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/anasayfa")
        self.assertIn("Kartaca - Anasayfa", 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 method name), and after each test, the tearDown method is automatically called. 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.

Author: Kartaca


Exit mobile version