DEV Community

Syed Ali
Syed Ali

Posted on

SELENIUM

Image description

What is selenium ?

  1. Selenium is a popular open-source automation framework
  2. It was created in 2004 by Jason Huggins
  3. it was limited to automating web applications.
  4. It was written entirely in Java but we can be used other languages like Python, Ruby, and PHP etc.

Table of Content :

  • Advantages / Disadvantages of Selenium
  • Basic Program of Selenium
  • Components of Selenium
  • Conclusion

Advantages / Disadvantages of Selenium

Selenium is a widely used tool for automating web applications and is appreciated for its many advantages. However, like any technology, it also has some disadvantages. Here is a comprehensive overview of both:

Advantages of Selenium

  1. Open Source: Selenium is free to use and open-source
  2. Cross-Browser Support: Selenium supports multiple browsers, including Chrome, Firefox, Safari, Edge, and Internet Explorer.
  3. Multi-Platform Compatibility: Selenium can run on various operating systems such as Windows, macOS, and Linux.
  4. Multiple Language Support: Selenium supports several programming languages, including Java, C, Python, Ruby, and JavaScript.
  5. Integration with Other Tools: Selenium can easily integrate with testing frameworks (like TestNG and JUnit) and CI/CD tools (like Jenkins).

Disadvantages of Selenium

  1. Steep Learning Curve:
    While Selenium can be powerful, it requires a good understanding of programming and testing concepts.

  2. Limited Support for Mobile Testing:
    While Selenium is primarily aimed at web applications, its support for mobile app testing is not as comprehensive as some dedicated mobile testing frameworks.

  3. No Automate-in Audio / Video Features:
    It cannot automate audio, video or images which are present on the web application

Basic Program – Open & quit the webpage.

from selenium import webdriver // Install Selenium & Webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from time import sleep

class Data:

    def __init__(self, url):
        self.url = url
        self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))


    def start(self):
        self.driver.get(self.url)

    def shutdown(self):
        self.driver.quit()

if __name__ == "__main__":
    url = "https://www.guvi.in"
    Call = Data(url)
    Call.start()
    Call.shutdown()
Enter fullscreen mode Exit fullscreen mode

Components of Selenium

Selenium comprises several key components:

Selenium WebDriver:

The most utilized component, WebDriver interacts directly with web elements across various browsers like Chrome, Firefox, Safari, and Edge, providing high control and accuracy for executing test scripts.

Selenium IDE:

IDE = Integrated Development Environment
It is nothing but a simple web-browser extension
It cannot make test reports
IDE allows users to record their actions on web applications and export scripts in various languages, making it an excellent tool for those new to automation.

Selenium Grid:

It is used to run parallel tests on multiple devices running different browsers at the same time

Conclusion

Selenium is a key resource in automated testing for web-based applications because of its flexibility, support for multiple browsers, integration skills, and robust community. which can decrease human efforts, improve test coverage, and speed up release cycles.

Top comments (0)