Remote linux ssh session terminal which is started in windows pycharm, how to run chrome broswer under this linux terminal?

已回答

My pycharm is in windows, and i config remote linux in pycharm.

And i start a ssh sessioin of this remote linux(Tools-->Start SSH Session...)

than try to run a python script showed as below:

```python

from time import sleep
from selenium import webdriver
import pytest

def test():
    driver = webdriver.Chrome('')
    soult = driver.get('http://google.com')
    sleep(30)
if __name__ == '__main__':
    test()

```

then failed, with error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/lib64/chromium-browser/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

This script can run successfully in normal linux termial(such as a linux terminal start by MobaXterm also installed in my windows pc).

So i think maybe there are some configuration need to be done with linux when you want to run it in pycharm.

Seems related with linux  display server, but i not sure about this, can you guys take a look, thx:)

```shell

sudo yum -y install Xvfb libXfont Xorg

sudo yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"

Xvfb :99 -screen 0 1024x768x24 &

export DISPLAY=:1

```

https://stackoverflow.com/questions/50790733/unknown-error-devtoolsactiveport-file-doesnt-exist-error-while-executing-selen

 

0

 Is there a specific reason why you using SSH Session instead of adding a Remote interpreter?

Also, indeed Using xvfb may be a solution here as mentioned on SO. You may also want to check the --headless option for Chrome (without GUI) 

chrome_options.add_argument("--headless")

Please double-check if you're using the same Python virtual environment on both PyCharm and  MobaXterm
 

0

请先登录再写评论。