DEV Community

DHANUSH
DHANUSH

Posted on

PYTHON SELENIUM

Python selenium archtecture is a layered system that allows developers to automate web browsers using the selenium webdriver APL.

  1. Client Layer(Test Script Layer)

*Languages supported:
selenium supports multiple languages like python,java,c#, ruby,and javaScriot, in our case Python is used.

*Bindings:
The python bindings are wrappers that translate python commands into http requests understood by webdriver.

  1. Selenium web driver API
  • webdriver is an interface that defines a set method for iterfacing with browsers (.get(),.click(),.send_keys(),etc.)
  • The webdriver API is language independent. Whenusing python,python binding convert method calls to JSON over HTTP.
  1. JSON wire protocol/W3C webdriver protocal
  • This is communication protocol that enables communication between the client and the browser driver.

  • In older versions selenium used the JSON wire protocol.

  1. BROWSER DRIVERS:
  • These are executables that act as middlemen between selenium and browsers.

Examples:

  • chromedriver for google chrome.
  • geckodriver for firefox
  • msedgedriver for microsoft edge.
  1. BROWSERS.
  • The driver controls the browser to perform tasks like loading pages, clicking buttons filling forms. etc.
  • The browsers sends responses back to the driver, which sends them back to the client.

PYTHON VIRTUAL ENVIRONMENT

  1. Dependency isolotion:
  • Prevents version conflicts between packages.
  • Each project can have its own set of dependencies.
  1. Project portability:
  • Makes it easier to share projects (using requirments.txt) without worrying about system wide pacjages.

3.Cleaner global environmrnt:

  • keeps the global python installation untouched and clean

4.Reproducibillity:

  • Help in reproducing exact environment for development, testing and deployment.

EXAMPLE:

1.Without virtual environment

You install Flask==2.0.0 for project A.later,project B need Flask==1.1.2. installing both globally causes conflicts.

2.With virtual environment:

Project A

python -m venv venvA
source venvA/bin/activate
pip install Flask==2.0.0

Project B

python -m venv venvB
source venvB/bin/activate
pip install Flask==1.1.2

Each project run independently without conflict.

Top comments (0)