首页 > 编程语言 > 详细

Python3 Selenium自动化web测试 ==> 第八节 WebDriver高级应用 -- 结束Windows中浏览器的进程

时间:2018-06-12 22:51:42      阅读:168      评论:0      收藏:0      [点我收藏+]

学习目的:


 

  掌握WebDriver的高级应用

 

正式步骤:


 

# -*-  coding:utf-8 -*-
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import WebDriverException
import unittest
import os
import time
import traceback

class WebdriverAPI(unittest.TestCase):
    def setUp(self):
        # 每个用例都执行,在单个用例运行前执行
        #打开浏览器
        self.driver = webdriver.Chrome()

    def tearDown(self):
        #每个用例都执行,在单个用例运行后执行
        #退出浏览器
        self.driver.quit()

    def test_closeBrowserProcess(self):
        url = https://www.baidu.com/
        self.driver.get(url)
        returnCode = os.system("taskkill /F /im " + "chrome.exe")
        if returnCode == 0:
            print("chrome process over")
        else:
            print("chrome process over fail")

if __name__ == __main__:
    unittest.main()

 

Python3 Selenium自动化web测试 ==> 第八节 WebDriver高级应用 -- 结束Windows中浏览器的进程

原文:https://www.cnblogs.com/wuzhiming/p/9164774.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!