Is it possible to run headless browser using Python-Selenium

0 votes
May 27, 2019 in Selenium by Fatima
6,771 views

1 answer to this question.

0 votes

Hi Fatima, you can run headless browser using Python-Selenium with following lines of code:

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys

opts = Options()
opts.set_headless()
assert opts.headless  # Operating in headless mode
browser = Firefox(executable_path=r"C:\Users\Anvi_R\Downloads\geckodriver-v0.24.0-win64\geckodriver.exe", options=opts)
browser.implicitly_wait(3)
browser.get('https://duckduckgo.com')

search_form = browser.find_element_by_id('search_form_input_homepage')
search_form.send_keys('real python')
search_form.submit()

results = browser.find_elements_by_id('links')
print(results[0].text)
answered May 27, 2019 by Anvi
• 14,150 points
Hello @Anvi

Can there be a headless version fr IE driver (using python)? Haven't found anywhere on the web.

Related Questions In Selenium

0 votes
1 answer
+1 vote
2 answers

Is it possible to scroll down in a webpage using selenium webdriver programmed on python?

I using next code for facebook for ...READ MORE

answered May 16, 2019 in Selenium by mslavikas@gmail.com
25,583 views
0 votes
1 answer
0 votes
1 answer

Selenium ChromeDriver issue - Want to run it in background, but not as headless browser

This is a flaw with ChromeDriver. Tried ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
7,466 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,150 points
15,183 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,711 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,608 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,680 views
0 votes
1 answer
0 votes
1 answer

Is it possible to do Database testing by using Selenium Webdriver?

Hey Kanika, Selenium Webdriver is limited to Testing Browser ...READ MORE

answered May 16, 2019 in Selenium by Anvi
• 14,150 points
544 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP