训练营第一天作业

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 TestBaidu():
def setup_method(self, method):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(5)
self.vars = {}

def teardown_method(self, method):
self.driver.quit()

def test_baidu(self):
self.driver.get(“https://www.baidu.com/”)
self.driver.set_window_size(1166, 796)
self.driver.find_element(By.ID, “kw”).click()
self.driver.find_element(By.ID, “kw”).send_keys(“测试开发”)
self.driver.find_element(By.ID, “su”).click()
text=self.driver.find_element(By.XPATH,“/html/body/div[2]/div[4]/div[1]/div[3]/div[2]/div/div[1]/h3/a/em”).text
# print(text)
assert “测试开发”==text