How to launch browsers using Python-Selenium?

0 votes
May 24 in Selenium by Nikita
35 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 by Anvi
• 13,840 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,250 points
1,079 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,130 points
327 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,650 points
3,846 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,130 points
15,878 views
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,420 points
499 views
0 votes
1 answer
0 votes
1 answer