简体   繁体   中英

Where is the problem about selenium with python?

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.

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 !

Try not use the "headless option":

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM