- 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 trigger headless test execution in Selenium with Python?
Selenium supports headless execution. In the Chrome browser, the headless execution can be implemented with the help of the ChromeOptions class. We have to create an object of this class and apply the add_arguments method to it. Finally, pass the parameter --headless to this method.
Let us obtain the title - About Careers at Tutorials Point - Tutorialspoint of the page launched in a headless mode −
Example
Code Implementation
from selenium import webdriver from selenium.webdriver.chrome.options import Options #object of Options class c = Options() #passing headless parameter c.add_argument("--headless") #adding headless parameter to webdriver object driver = webdriver.Chrome(executable_path='../drivers/chromedriver', options=c) # implicit wait time driver.implicitly_wait(5) # url launch driver.get("https://www.tutorialspoint.com/about/about_careers.htm") print('Page title: ' + driver.title) # driver quit driver.quit()
Output
Advertisements