Selenium crashing with selenium.common.exceptions.WebDriverException: Message: newSession

后端 未结 3 2340
说谎
说谎 2021-02-19 22:43

OS: Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-1066-aws x86_64)

Selenium Version: selenium==3.6.0

Browser: Mozilla Firefox 63.0

Geckodriver version : geckodr

3条回答
  •  时光取名叫无心
    2021-02-19 23:20

    In your log is the following line:

    1540501901605 geckodriver ERROR Address in use (os error 98)

    Which indicates that the driver is trying to use a port which is already used by some other process. Since the log doesn't show which port it is, you can run the driver with strace:

    strace geckodriver 2>&1 | grep -iE 'bind|getsockname'
    

    In my case I get these lines:

    bind(3, {sa_family=AF_INET, sin_port=htons(4444), sin_addr=inet_addr("127.0.0.1")}, 16) = 0

    getsockname(3, {sa_family=AF_INET, sin_port=htons(4444), sin_addr=inet_addr("127.0.0.1")}, [128->16]) = 0

    You can then check which process is using the port (for example):

    netstat -tulpn | grep -i 4444 
    

    In my case returning:

    tcp 0 0 127.0.0.1:4444 0.0.0.0:* LISTEN 31471/geckodriver

    According to a issue about geckodriver port logging, you can let the os allocate a free port:

    geckodriver --port 0
    

    If all this doesn't work out, there may an incompatibility between your version of geckodriver and selenium, as this error in the log seems to suggest:

    geckodriver::marionette TRACE <- [1,1,{"error":"unknown command","message":"newSession","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178:5

    I am using the following versions:

    • firefox 62.0.3
    • geckodriver 0.23.0
    • selenium 3.14.1

提交回复
热议问题