(1)selenium 基础-浏览器操作_打开/关闭网页

打开网页

(1)打开Pycharm,新建python 

file->new->python package

 (2)新建Python file

在建好的python package下新建Python File

(3)进入主题,浏览器操作——打开网页

#coding : utf-8
from selenium import webdriver #加载webdriver方法
driver = webdriver.Firefox() #创建FireFox对象,调用firefox浏览器
driver.get("https://www.baidu.com/") # 在firefox中输入需要访问的URL路径

关闭网页

关闭有两种方法

(1)close()

close()关闭的是当前的窗口,用于某个具体的窗口。

driver.close()

  (2)   quit()

quit()用于关闭所有关联的窗口,并退出驱动。需要释放资源的话就采用该方法。

driver.quit()

猜你喜欢

转载自blog.csdn.net/panyueke/article/details/86551126