How to launch browsers using Python-Selenium

0 votes
May 24, 2019 in Selenium by Nikita
895 views

1 answer to this question.

0 votes

Hey Nikita, to launch browser in Python-Selenium, you can use these lines of code:

  1. 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')
  2. 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")
  3. 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.

answered May 24, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

0 votes
1 answer

How to upload a resume to a website using selenium in python?

Use this code, this will help you: from ...READ MORE

answered Apr 20, 2018 in Selenium by Vardy
• 2,360 points
2,596 views
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,910 points
2,413 views
0 votes
1 answer

How to Check if any alert exists in selenium using Python

This might work for you. It did ...READ MORE

answered May 10, 2018 in Selenium by king_kenny
• 3,710 points
12,601 views
0 votes
2 answers
0 votes
2 answers
0 votes
1 answer

How to Hover using Mouse in python using Webdriver

from selenium.webdriver.common.action_chains import ActionChains def hover(self): ...READ MORE

answered Aug 8, 2018 in Selenium by Meci Matt
• 9,460 points
2,199 views
0 votes
1 answer

How to measure page load time of a website using Selenium-Python?

Hello Damodar, following test script allows you ...READ MORE

answered Jul 22, 2019 in Selenium by Anvi
• 14,150 points
11,274 views
0 votes
1 answer
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