当前位置:网站首页>Actual combat - store login test

Actual combat - store login test

2022-06-21 17:03:00 Expert of explosive liver fist

import time

import pytest

# Import selenium Of webdriver
from selenium import webdriver

class Testlogin:
    # Before the test ( Open the browser , Enter login URL )
    def setup_class(self):
        # Open Google browser 
        self.driver=webdriver.Chrome()
        # Get the website address you need to visit 
        self.driver.get('http://39.98.138.157/shopxo/index.php?s=/index/user/logininfo.html')

    # The user login --- Login successful 
    def test_01(self):
        # Get the name of the account input box accounts, And fill in the account number qiushui
        self.driver.find_element_by_name('accounts').send_keys('qiushui')
        # Get the name of the password input box pwd, And fill in the password 123456
        self.driver.find_element_by_name('pwd').send_keys('123456')
        # Get the login button xpath Address 
        self.driver.find_element_by_xpath('/html/body/div[4]/div/div[2]/div[2]/form/div[3]/button').click()
        # window maximizing 
        self.driver.maximize_window()

    # The user login --- Login failed 
    def test_02(self):
        # Get the name of the account input box accounts, And fill in the wrong account number qiushui2
        self.driver.find_element_by_name('accounts').send_keys('qiushui2')
        # Get the name of the password input box pwd, And fill in the password 123456
        self.driver.find_element_by_name('pwd').send_keys('123456')
        # Get the login button xpath Address 
        self.driver.find_element_by_xpath('/html/body/div[4]/div/div[2]/div[2]/form/div[3]/button').click()
       # window maximizing 
        self.driver.maximize_window()


    # After the test ( rest 5 Seconds later , Close the browser )
    def teardown_class(self):
        time.sleep(5)
        self.driver.quit()

# Perform the test 
if __name__ == '__main__':
    pytest.main(['-vs','test_login.py'])
原网站

版权声明
本文为[Expert of explosive liver fist]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211318464343.html