训练营第一天作业230412

作业内容

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2023/4/12 16:03
# @Author  : Shenghao Yang
# @FileName: test_lagou.py
import time
from selenium import webdriver
from selenium.webdriver.common.by import By


class TestLagou:
    # 启动方法
    def setup_method(self, method):
        self.driver = webdriver.Chrome()
        self.driver.get("https://www.lagou.com/")
        self.vars = {}
        self.driver.maximize_window()

    # 结束方法
    def teardown_method(self, method):
        self.driver.quit()

    # 执行方法
    def test_lagou(self):
        self.driver.find_element(By.ID, "cboxClose").click()
        self.driver.find_element(By.ID, "search_input").click()
        self.driver.find_element(By.ID, "search_input").send_keys("字节跳动")
        self.driver.find_element(By.ID, "search_button").click()
        time.sleep(3)
        # 实际结果
        res = self.driver.find_element(By.CSS_SELECTOR, ".company-card__1BXKp h3")
        print(res.text)