from selenium import webdriver
from time import sleep, strftime, localtime, time
from selenium.webdriver.common.by import By
from Common import project_path
class Test:
def __init__(self, Test_driver):
self.driver = Test_driver
def save_screenshot(self):
file_name = strftime("%Y%m%d-%H%M%S", localtime(time())) + ".png"
# self.driver.save_screenshot(project_path.Test_screenshot + "\\" + file_name) #移动到指定文件夹中
self.driver.save_screenshot(file_name)
driver.quit()
def login(self):
element = driver.find_element(By.ID, value="kw")
element.send_keys("自动化测试")
sleep(1)
self.save_screenshot()
if __name__ == '__main__':
driver = webdriver.Chrome() # 打开浏览器
driver.get("https://www.baidu.com/")
Test(driver).login()
2241
100
101
357
63
14
1
76
1528
欢迎来到testingpai.com!
注册 关于