老师,为什么driver.close()没用

来源:2-8 如何使用Expected_conditions判断元素是否可见

cloudonthesun

2021-07-14

按照视频中的代码,运行完脚本后进程还是在

**************************************************************************************

#coding=utf-8

from selenium import webdriver

from selenium.webdriver.support import expected_conditions as ec

from selenium.webdriver.support.wait import WebDriverWait

from selenium.webdriver.common.by import By

import time


#1.创建Chrome的driver

option = webdriver.ChromeOptions()

# 防止打印一些无用的日志

option.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])

driver = webdriver.Chrome(options=option)

driver.get("http://www.5itest.cn/register")

time.sleep(5)


# element = driver.find_element_by_class_name("controls")

locator = (By.CLASS_NAME,"controls")

print(WebDriverWait(driver,10).until(ec.visibility_of_element_located(locator)))

driver.close()

*********************************************************************************

http://img.mukewang.com/szimg/60eea2cb09e8943b19730152.jpg

http://img.mukewang.com/szimg/60eea255093ddc6322150293.jpg

写回答

2回答

Mushishi

2021-07-15

哈哈。你需要了解close 和driver.quite()的区别。你如果关闭驱动就用quite
0
3
cloudonthesun
回复
Mushishi
谢谢老师
2021-07-19
共3条回复

Mushishi

2021-07-19

对。close只是关闭窗口。quite是关闭窗口加进程。
0
0

Selenium3与Python3实战Web自动化测试框架

打破无项目经验、无框架经验瓶颈,实战Web自动化测试框架!

1886 学习 · 1093 问题

查看课程