python中close的⽤法_使⽤python的Selenium中close()和
qui。。。
在某些情况下,我们需要打开的内容多于具有多个标签的浏览器。为了关闭这些会议quit()和close()⽅法,硒被使⽤。但是它们之间有区别,它们在下⾯列出-该close()⽅法可以关闭浏览器的焦点。whilequit()⽅法与driver.dispose()⽅法⼀起使⽤,该⽅法关闭每个连续的窗⼝。
该close()⽅法将关闭当前正在使⽤的窗⼝。whilequit()⽅法挂起所有驱动程序会话和实例,从⽽关闭每个打开的窗⼝。
⽰例
close()⽅法的代码实现。from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:\\")
# to maximize the browser window
selenium怎么使用
driver.maximize_window()
#get method to launch the URL
<("the-internet.herokuapp/windows")
#to refresh the browser
driver.find_element_by_link_text("Click Here").click()
#to fetch the first child window handle
chwnd = driver.window_handles[1]
#to switch focus the first child window handle
driver.switch_to.window(chwnd)
#to close the first child window in focus
driver.close()
quit()⽅法的代码实现。from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:\\")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
<("the-internet.herokuapp/windows")
#to refresh the browser
driver.find_element_by_link_text("Click Here").click()
#to fetch the first child window handle
chwnd = driver.window_handles[1]
#to switch focus the first child window handle
driver.switch_to.window(chwnd) #to close the all the windows driver.quit()

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。