SoFunction
Updated on 2024-11-12

Teach you to use Python + selenium build automation test environment

I. Environment Setup

1, install python + pycharm software . python installation site official website:/about/

Choose the latest version according to your computer system

Download locally, choose the installation path and configure the environment variables

Verify that the installation was successful Enter cmd into the search to open a command window Enter python to display the version number to indicate that the installation was successful.

2. pycharm software installation address:/pycharm/download/#section=windows

Choose the Pro or Community edition according to your needs

The first time you install it, open New Project and create the path where the project will be stored in Location.

To add the interpreter File, select settings and click project interpret to add the module pymysql.

II. Steps

1, in the command window to install the module used to install the module selenium

pip install selenium

3. Install the browser launcher

2. Open pycharm to create a new code file and edit the code.

# Import the module used

from selenium improt  webdriver

# Launch the browser

# Launch the browser
driver = ('Downloaded browser drivers')

3. Send the request, and the URL.

('URL')

4. Writing your own code

III. Server deployment

# Create instance objects Via ssh protocol

ssh = ()

# Connection servers Trust servers

ssh.set_missing_host_key_policy(())

# connect remote ip port username password

(ipd address, "username", "password")

# Pipeline to find running package names and remove grep shaped package names
 
stdin,stdout,stder = ssh.exec_command('ps -ef|grep package name |grep -v grep')
output = ().decode()
print(output)
 
if 'Printed out installer paths and running packages' in output:
    
    # find and extract information split split string
    parts = ('')
     # List Builder Remove Spaces
    parts = [part for part in parts if part!='']
    pid = parts[1]
    # Kill the process
    ssh.exec_cmmand(f'kill-9{pid}')
# Remove old installation packages
ssh.exec_command('rm -f ')
# Upload new installer file
sftp = ssh.open_sftp()
(r'Installation package name')
()

To this article on the teach you to use Python selenium build automated test environment is introduced to this article, more related python selenium automated test environment content please search for my previous articles or continue to browse the following related articles I hope you will support me in the future more!