How to launch browsers using Python-Selenium?

0 votes
May 24, 2019 in Selenium by Nikita
74 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,010 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,370 points
1,190 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,870 points
548 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
5,538 views
0 votes
2 answers

How to get HTML Source of WebElement in Selenium WebDriver using Python?

You can read innerHTML attribute to get source of ...READ MORE

answered Jun 13, 2018 in Selenium by Samarpit
• 5,870 points
26,026 views
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
822 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,010 points
1,980 views
0 votes
1 answer