0

When I run the code it takes about 5-6 sec to execute, after than nothings happens. I get no error, but the code is simply not working. Please, help me fast I've got a project to do in a month.

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
opts = Options()
opts.set_headless()
assert opts.headless
browser = Firefox(options=opts)
browser.get("https://duckduckgo.com")

Sorry about not knowing enough about stackoverflow. I think I wrote everything to the code entry.

4
  • Do you have geckodriver? If you don't just download it here Commented Jul 31, 2019 at 7:30
  • Are you sure that it doesn't work? Because browser runs in headless mode and you will not see anything. did you check response? Commented Jul 31, 2019 at 7:58
  • your code definitely works. You just use headless option, which means the opened browser will be invisible. Headless browser is just a browser with no GUI to make selenium faster. Commented Jul 31, 2019 at 8:54
  • @sertsedat headless won't make it any faster Commented Jul 31, 2019 at 18:23

2 Answers 2

2

Your code is perfectly working for me.

opts.set_headless() browser = Firefox(options=opts)

This operation will create an option which hide the browser, then you set this option to you recently created Firefox tab. Once you open the duckduckgo url,

It takes a few seconds to you program to open Firefox, but... you reach the end of your program and you browser is HIDING Check with top command and you'll see Firefox still running. Try to execute the same code but without the opts.set_headless() line.

Good Luck !

Sign up to request clarification or add additional context in comments.

Comments

0

Try not use the "headless option":

from selenium.webdriver import Firefox
browser = Firefox()
browser.get("https://duckduckgo.com")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.