基本硒测试用例

这是使用 python Unittest 库的 Selenium 测试用例的基本示例

from selenium import webdriver
import unittest

class SeleniumTest(Unittest.testcase):

    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(30)
        
    def test(self):
        self.driver.get("https//www.google.com")
        self.driver.find_element_by_id("lst-ib").send_keys("python")
        self.driver.find_element_by_css_selector("span[class=\"sbico\"]").click()

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