Hey Nikita, to launch browser in Python-Selenium, you can use these lines of code:
- For Chrome Browser:
driver = webdriver.Chrome("C:\\Users\\Anvi_R\\Downloads\\chromedriver_win32\\chromedriver.exe")
drv.implicitly_wait(2)
drv.maximize_window()
driver.get('https://www.google.com')
-
For Firefox Browser:
drv = webdriver.Firefox(executable_path=r"C:\Users\Anvi_R\Downloads\geckodriver-v0.24.0-win64\geckodriver.exe")
drv.implicitly_wait(2)
drv.maximize_window()
drv.get(r"https://www.google.com")
-
For Internet Explorer Browser:
drv = webdriver.Ie(r"C:\Users\Anvi_R\Downloads\IEDriverServer_x64_3.14.0\IEDriverServer.exe")
drv.implicitly_wait(2)
drv.maximize_window()
drv.get(r"https://www.google.com")
Note that for Firefox browser, if we execute the script without "executable_path", it gives an "NotADirectoryError". As Selenium client bindings tries to locate the geckodriver executable from the system PATH. So, we need to pass the Key "executable_path" along with the value referring to the absolute path of the GeckoDriver.