How to open Firefox Developer Edition through Selenium

后端 未结 2 1246
栀梦
栀梦 2020-12-02 00:54

Following some tutorials on Selenium, I installed the geckodriver. In order to run a simple code on python to run Selenium, I have to specify this path in the c

相关标签:
2条回答
  • 2020-12-02 01:29

    The Firefox Developer Edition browser is not installed at the conventional location where regular Firefox browser gets installed. In my Windows 8 box Firefox Developer Edition browser got installed within the directory:

    C:\Program Files\Firefox Developer Edition
    

    Now, while invoking Firefox Developer Edition browser you need to pass the absolute path of the Firefox Developer Edition binary through the argument firefox_binary as follows:

    • Code Block:

      from selenium import webdriver
      from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
      
      firefox_dev_binary = FirefoxBinary(r'C:\Program Files\Firefox Developer Edition\firefox.exe')
      driver = webdriver.Firefox(firefox_binary=firefox_dev_binary, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
      driver.get('https://www.google.co.in')
      print("Page Title is : %s" %driver.title)
      # driver.quit()
      
    • Console Output:

      Page Title is : Google
      
    • Browser Snapshot:


    This usecase

    As you are on Linux you need to provide the absolute path of:

    • Firefox Developer Edition binary
    • GeckoDriver binary

    So your effective code block will be:

    from selenium import webdriver
    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    
    firefox_dev_binary = FirefoxBinary('/path/to/Firefox Developer Edition/firefox')
    driver = webdriver.Firefox(firefox_binary=firefox_dev_binary, executable_path='/home/xx/Downloads/geckodriver-v0.24.0-linux64/geckodriver')
    driver.get('https://www.google.co.in')
    print("Page Title is : %s" %driver.title)
    # driver.quit()
    
    0 讨论(0)
  • 2020-12-02 01:45

    You can use FirefoxBinary as described here: Setting path to firefox binary on windows with selenium webdriver

    To set the custom path to Firefox you need to use FirefoxBinary:

    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
    
    binary = FirefoxBinary('F:\FirefoxPortable\Firefox.exe')
    driver = webdriver.Firefox(firefox_binary=binary)
    
    0 讨论(0)
提交回复
热议问题