- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to hide Firefox window (Selenium WebDriver)?
We can hide the Firefox window in Selenium webdriver. This can be done by making the browser headless. We shall achieve this with the FirefoxOptions class. We shall then create an object option of that class.
We have to make the browser setting options.headless to True value. This driver object shall then receive this information. We need to have the import statement: from selenium.webdriver.firefox.options import Options as FirefoxOptions for adding the FirefoxOptions class.
Syntax
options = webdriver.FirefoxOptions() options.headless = True
Example
Code Implementation.
from selenium import webdriver from selenium.webdriver.firefox.options import Options as FirefoxOptions #object of FirefoxOptions options = webdriver.FirefoxOptions() #setting headless parameter options.headless = True driver = webdriver.Firefox(executable_path="C:\geckodriver.exe", options=options) driver.implicitly_wait(0.8) driver.get("https://www.tutorialspoint.com/tutorialslibrary.htm") #identify element n = driver.find_element_by_xpath("//*[text()='Library']") #perform click n.click(); print("Page title after click: " + driver.title) driver.quit()
Output
- Related Articles
- How to set Proxy in Firefox using Selenium WebDriver?
- How does Selenium Webdriver handle SSL certificate in Firefox?
- How to get Firefox working with Selenium WebDriver on Mac OSX?
- How to close child browser window in Selenium WebDriver using Java?
- How to maximize the browser window in Selenium WebDriver using C#?
- Handle Firefox Not Responding While Using Selenium WebDriver With Python?
- Where can I find a definitive Selenium WebDriver to Firefox Compatibility Matrix?
- How to set window size using phantomjs and selenium webdriver in Python?
- How to open browser window in incognito/private mode using python selenium webdriver?
- How can I close a specific window using Selenium WebDriver with Java?
- How to open a new window on a browser using Selenium WebDriver for python?
- How to open a browser window in full screen using Selenium WebDriver with C#?
- How to Resize Browser Window in WebDriver?
- How to Download & Install Selenium WebDriver?
- How to get rid of Firefox logging in Selenium?

Advertisements