Selenium IDE
1. Video
2. Description
- Using a localhost web project as testing target, this project implement by Django frame.
- This web request user write a table and submit.
- This project connect to the local MySQL database to store the info.
- Using Selenium IDE to do the auto testing.
- Login test
- positive
- negative
- not give username
- Write table test
- positive
- negative
- not give order name
- Login test
Because for auto testing, temporarily close the verify-code part.
3. Selenium IDE
4. Python code
# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class TestTableFillpositive():
def setup_method(self, method):
self.driver = webdriver.Firefox()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_tableFillpositive(self):
self.driver.get("http://127.0.0.1:8001/login/")
self.driver.find_element(By.ID, "LAY-user-login-username").click()
self.driver.find_element(By.ID, "LAY-user-login-username").send_keys("admin")
self.driver.find_element(By.ID, "LAY-user-login-password").click()
self.driver.find_element(By.ID, "LAY-user-login-password").send_keys("123456")
self.driver.find_element(By.ID, "LAY-user-login-vercode").click()
self.driver.find_element(By.ID, "LAY-user-login-vercode").send_keys("0644")
self.driver.find_element(By.ID, "loginButton").click()
WebDriverWait(self.driver, 30).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, ".layui-logo")))
self.driver.find_element(By.LINK_TEXT, "需求管理").click()
self.driver.find_element(By.LINK_TEXT, "需求申请").click()
self.driver.switch_to.frame(0)
self.driver.find_element(By.CSS_SELECTOR, ".layui-select-title > .layui-input").click()
self.driver.find_element(By.CSS_SELECTOR, "dd:nth-child(2)").click()
self.driver.find_element(By.ID, "order_date").click()
self.driver.find_element(By.CSS_SELECTOR, "tr:nth-child(2) > td:nth-child(7)").click()
self.driver.find_element(By.ID, "order_name").click()
self.driver.find_element(By.ID, "order_name").send_keys("name")
self.driver.find_element(By.ID, "order_sys").click()
self.driver.find_element(By.ID, "order_sys").send_keys("system")
self.driver.find_element(By.CSS_SELECTOR, ".layui-unselect:nth-child(4) > .layui-anim").click()
self.driver.find_element(By.ID, "order_desc").click()
self.driver.find_element(By.ID, "order_desc").send_keys("request")
self.driver.find_element(By.ID, "submitBtn").click()