Using chromedriver with selenium/python/ubuntu

后端 未结 7 1181
野趣味
野趣味 2020-12-25 11:53

I am trying to execute some tests using chromedriver and have tried using the following methods to start chromedriver.

driver = webdriver.Chrome(\'/usr/local         


        
相关标签:
7条回答
  • 2020-12-25 12:26

    Following the suggestion from https://askubuntu.com/questions/539498/where-does-chromedriver-install-to I was able to make it work like this:

    1. Installed the chromium-chromedriver:

      sudo apt-get install chromium-chromedriver
      
    2. Adding the path to the selenium line:

      driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
      

    Note that this opens Chromium and not Chrome. Hope it was helpful.

    0 讨论(0)
  • 2020-12-25 12:31

    As the message says: ChromeDriver executable needs to be available in the path.

    So is it in the path? What is the output of:

    $ cd
    $ chromedriver --version
    

    If you don’t see the version, chromedriver is definitively not in the PATH.

    I don’t tell webdriver where to find chromedriver otherwise. – I use the Ubuntu package “chromium-chromedriver”, but it drops the binary in /usr/lib/chromium-browser/chromedriver, which is not in my PATH. So I put a soft link in /usr/bin.

    0 讨论(0)
  • 2020-12-25 12:39

    hope this will be useful for some who did like me. For my case i left preceding slash in the path did "home/user/chromedriver" instead of "/home/user/chromedriver"

    0 讨论(0)
  • 2020-12-25 12:40

    You need to make sure the standalone ChromeDriver binary is either in your path or available in the webdriver.chrome.driver environment variable and then try to use absolute path to that binary. Below is the code for java -

        File chromeDriver = new File("/usr/bin/chromedriver");
        System.setProperty("webdriver.chrome.driver", chromeDriver.getAbsolutePath());
        driver = new ChromeDriver();
    
    0 讨论(0)
  • 2020-12-25 12:48

    The following should normally work:

    driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')
    

    Note that in your question there was no preceding '/' in the path.

    Additionally, make sure that the chromedriver executable located in /usr/local/bin/ has appropriate file permissions, i.e. that it can be executed:

    > chmod 777 /usr/local/bin/chromedriver
    
    0 讨论(0)
  • 2020-12-25 12:48

    Just pass the binary location as argument to it and not just the directory conatining it. So if it lies in /usr/bin directory, then run below command:

    driver = webdriver.Chrome("/usr/bin/chromedriver")
    

    This worked for me in ubuntu and adding path to bashrc is not working. Give it a try.

    0 讨论(0)
提交回复
热议问题