Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Having difficulties using selenium module

I’m still new to python and I was experimenting with selenium. It opens a Firefox browser when I use it directly from the Windows terminal. But when I change the directory to desktop and try to open the browser from there, it say the ‘geckodriver’ isn’t in Path. I have the driver in path

This is my code:

from selenium import webdriver

browser = webdriver.Firefox()

And sometimes the browser opens but it closes immediately

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

According to docs: Selenium Documentation, you have to initiate driver, you can do this with hard coded location, example:

from selenium.webdriver.firefox.service import Service
from selenium import webdriver

service = Service(executable_path="/path/to/geckodriver")
driver = webdriver.Firefox(service=service)

then, to take an action on browser, you need to get a page, example:

driver.get("https://www.selenium.dev/selenium/web/web-form.html")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading